Add stub interface

This commit is contained in:
Paul Campbell 2018-05-12 18:08:02 +01:00
parent e29f08c4f9
commit 1b2d540078
9 changed files with 160 additions and 0 deletions

View file

@ -0,0 +1,13 @@
package net.kemitix.gitdb;
import net.kemitix.mon.TypeAlias;
public class Author extends TypeAlias<String> {
protected Author(String value) {
super(value);
}
public static Author name(final String name) {
return new Author(name);
}
}

View file

@ -0,0 +1,13 @@
package net.kemitix.gitdb;
import net.kemitix.mon.TypeAlias;
public class Branch extends TypeAlias<String> {
protected Branch(final String value) {
super(value);
}
static Branch name(final String name) {
return new Branch(name);
}
}

View file

@ -0,0 +1,18 @@
package net.kemitix.gitdb;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class Document<T> {
public static <T> Document<T> create(Key key, T value) {
return new Document<>(key, value);
}
@Getter
private final Key key;
@Getter
private final T value;
}

View file

@ -4,6 +4,7 @@ import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.stream.Stream;
public interface GitDB { public interface GitDB {
@ -16,4 +17,24 @@ public interface GitDB {
Repository getRepository(); Repository getRepository();
Path getGitDir(); Path getGitDir();
String get(Branch branch, Key key);
<T> T get(Branch branch, Key key, Class<T> type);
Stream<String> getFiles(Branch branch, Key key);
<T> Stream<T> getFiles(Branch branch, Key key, Class<T> type);
<T> T save(Branch branch, Message message, Document<T> document, Author author);
String delete(Branch branch, Key key, Message message, Author author);
void tag(Reference reference);
void createBranch(Reference reference);
Stream<String> getAllBranches();
Transaction createTransaction(Branch branch);
} }

View file

@ -6,6 +6,7 @@ import org.eclipse.jgit.api.errors.GitAPIException;
import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.Repository;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.stream.Stream;
class GitDBLocal implements GitDB { class GitDBLocal implements GitDB {
@ -29,4 +30,55 @@ class GitDBLocal implements GitDB {
public void close() { public void close() {
repository.close(); repository.close();
} }
@Override
public String get(Branch branch, Key key) {
return null;
}
@Override
public <T> T get(Branch branch, Key key, Class<T> type) {
return null;
}
@Override
public Stream<String> getFiles(Branch branch, Key key) {
return null;
}
@Override
public <T> Stream<T> getFiles(Branch branch, Key key, Class<T> type) {
return null;
}
@Override
public <T> T save(Branch branch, Message message, Document<T> document, Author author) {
return null;
}
@Override
public String delete(Branch branch, Key key, Message message, Author author) {
return null;
}
@Override
public void tag(Reference reference) {
}
@Override
public void createBranch(Reference reference) {
}
@Override
public Stream<String> getAllBranches() {
return null;
}
@Override
public Transaction createTransaction(Branch branch) {
return null;
}
} }

View file

@ -0,0 +1,13 @@
package net.kemitix.gitdb;
import net.kemitix.mon.TypeAlias;
public class Key extends TypeAlias<String> {
protected Key(final String value) {
super(value);
}
public static Key name(final String name) {
return new Key(name);
}
}

View file

@ -0,0 +1,12 @@
package net.kemitix.gitdb;
import net.kemitix.mon.TypeAlias;
public class Message extends TypeAlias<String> {
protected Message(final String value) {
super(value);
}
public static Message message(final String message) {
return new Message(message);
}
}

View file

@ -0,0 +1,9 @@
package net.kemitix.gitdb;
import net.kemitix.mon.TypeAlias;
public class Reference extends TypeAlias<String> {
protected Reference(String value) {
super(value);
}
}

View file

@ -0,0 +1,9 @@
package net.kemitix.gitdb;
import net.kemitix.mon.TypeAlias;
public class Transaction extends TypeAlias<String> {
protected Transaction(String value) {
super(value);
}
}