Add missing javadoc and update parameter names and remove bp constructor

This commit is contained in:
Paul Campbell 2018-06-15 19:13:31 +01:00
parent 53596f4254
commit 58daa2a6a6
4 changed files with 21 additions and 14 deletions

View file

@ -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.

View file

@ -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);
}

View file

@ -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());
}

View file

@ -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<String> get(String key) throws IOException {
public Optional<String> 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