Make BranchResource and TagResource extend a common class

Add a new abstract class, RefResource, that defines access methods to
get the ref name and revision.

Make both BranchResource and TagResource derive from RefResource, and
add the missing implementations in TagResource.

This will make it easier to consolidate common code that can be used
for both branch and tag related endpoints.

Change-Id: Ib44d621e34ce2b1077349db0037d960155b790e0
This commit is contained in:
David Pursehouse
2016-12-02 22:13:20 +09:00
parent 3ea9a7e380
commit eff1643099
3 changed files with 50 additions and 6 deletions

View File

@@ -19,7 +19,7 @@ import com.google.gerrit.extensions.restapi.RestView;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.inject.TypeLiteral;
public class BranchResource extends ProjectResource {
public class BranchResource extends RefResource {
public static final TypeLiteral<RestView<BranchResource>> BRANCH_KIND =
new TypeLiteral<RestView<BranchResource>>() {};
@@ -38,10 +38,12 @@ public class BranchResource extends ProjectResource {
return new Branch.NameKey(getNameKey(), branchInfo.ref);
}
@Override
public String getRef() {
return branchInfo.ref;
}
@Override
public String getRevision() {
return branchInfo.revision;
}