From 58daa2a6a661c5e4d604af0458202f2e15f50988 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Fri, 15 Jun 2018 19:13:31 +0100 Subject: [PATCH] Add missing javadoc and update parameter names and remove bp constructor --- .../java/net/kemitix/gitdb/GitDBBranch.java | 6 ++++-- .../net/kemitix/gitdb/impl/GitDBBranchImpl.java | 4 ++-- .../java/net/kemitix/gitdb/impl/GitDBRepo.java | 8 ++++++++ .../gitdb/impl/GitDBTransactionImpl.java | 17 +++++++---------- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/main/java/net/kemitix/gitdb/GitDBBranch.java b/src/main/java/net/kemitix/gitdb/GitDBBranch.java index f6bd3ba..aa68421 100644 --- a/src/main/java/net/kemitix/gitdb/GitDBBranch.java +++ b/src/main/java/net/kemitix/gitdb/GitDBBranch.java @@ -75,16 +75,18 @@ public interface GitDBBranch { * Begins a new anonymous transaction. * * @return a new Transaction + * @throws IOException error writing transaction branch */ GitDBTransaction transaction() throws IOException; /** * Begins a new named transaction. * - * @param name the transaction name + * @param transactionName the transaction name * @return a new Transaction + * @throws IOException error writing transaction branch */ - GitDBTransaction transaction(String name) throws IOException; + GitDBTransaction transaction(String transactionName) throws IOException; /** * Gets the name of the branch. diff --git a/src/main/java/net/kemitix/gitdb/impl/GitDBBranchImpl.java b/src/main/java/net/kemitix/gitdb/impl/GitDBBranchImpl.java index 1adecf9..8be9f1f 100644 --- a/src/main/java/net/kemitix/gitdb/impl/GitDBBranchImpl.java +++ b/src/main/java/net/kemitix/gitdb/impl/GitDBBranchImpl.java @@ -110,9 +110,9 @@ class GitDBBranchImpl implements GitDBBranch { } @Override - public GitDBTransaction transaction(String name) throws IOException { + public GitDBTransaction transaction(final String transactionName) throws IOException { final Ref ref = gitDBRepo.createBranch(branchRef, UUID.randomUUID().toString()); - final GitDBBranch branch = new GitDBBranchImpl(ref, gitDBRepo, userName, userEmailAddress, name); + final GitDBBranch branch = new GitDBBranchImpl(ref, gitDBRepo, userName, userEmailAddress, transactionName); return new GitDBTransactionImpl(this, branch); } diff --git a/src/main/java/net/kemitix/gitdb/impl/GitDBRepo.java b/src/main/java/net/kemitix/gitdb/impl/GitDBRepo.java index 2095f5b..1eb03c1 100644 --- a/src/main/java/net/kemitix/gitdb/impl/GitDBRepo.java +++ b/src/main/java/net/kemitix/gitdb/impl/GitDBRepo.java @@ -228,6 +228,14 @@ class GitDBRepo { return keyRemover.remove(branchRef, key); } + /** + * Create a new branch. + * + * @param branchRef the branch source + * @param name the name of the new branch + * @return the Ref of the new branch + * @throws IOException error writing the branch + */ Ref createBranch(final Ref branchRef, final String name) throws IOException { return writeHead(branchRef.getName(), branchRef.getObjectId()); } diff --git a/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java b/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java index 4fa6db1..916e396 100644 --- a/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java +++ b/src/main/java/net/kemitix/gitdb/impl/GitDBTransactionImpl.java @@ -22,6 +22,7 @@ package net.kemitix.gitdb.impl; import com.github.zafarkhaja.semver.Version; +import lombok.RequiredArgsConstructor; import net.kemitix.gitdb.GitDBBranch; import net.kemitix.gitdb.GitDBTransaction; @@ -33,28 +34,24 @@ import java.util.Optional; * * @author Paul Campbell (pcampbell@kemitix.net) */ +@RequiredArgsConstructor class GitDBTransactionImpl implements GitDBTransaction { private final GitDBBranch base; private final GitDBBranch branch; - GitDBTransactionImpl(final GitDBBranch base, final GitDBBranch branch) { - this.base = base; - this.branch = branch; - } - @Override - public Optional get(String key) throws IOException { + public Optional get(final String key) throws IOException { return branch.get(key); } @Override - public GitDBBranch put(String key, String value) throws IOException { + public GitDBBranch put(final String key, final String value) throws IOException { return branch.put(key, value); } @Override - public GitDBBranch remove(String key) throws IOException { + public GitDBBranch remove(final String key) throws IOException { return branch.remove(key); } @@ -69,8 +66,8 @@ class GitDBTransactionImpl implements GitDBTransaction { } @Override - public GitDBTransaction transaction(String name) throws IOException { - return branch.transaction(name); + public GitDBTransaction transaction(final String transactionName) throws IOException { + return branch.transaction(transactionName); } @Override