Make IncludedInDetail a static class of IncludedInResolver

IncludedInDetail is only used by the IncludedIn change REST API
endpoint and in the tests for the IncludedInResolver.

Make it a static class of IncludedInResolver and rename it to
Result which is a bit shorter.

Remove the now unused IncludedInDetail class from gerrit-common.

Change-Id: I8255dd99ead8ba4798ab1dd9a05880e2facbd249
This commit is contained in:
David Pursehouse
2016-02-18 16:00:12 +09:00
parent 3db8abaf63
commit 29d8a29f52
4 changed files with 35 additions and 57 deletions

View File

@@ -14,7 +14,6 @@
package com.google.gerrit.server.change;
import com.google.gerrit.common.data.IncludedInDetail;
import com.google.gerrit.extensions.config.ExternalIncludedIn;
import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.restapi.BadRequestException;
@@ -80,7 +79,7 @@ class IncludedIn implements RestReadView<ChangeResource> {
throw new ResourceConflictException(err.getMessage());
}
IncludedInDetail d = IncludedInResolver.resolve(r, rw, rev);
IncludedInResolver.Result d = IncludedInResolver.resolve(r, rw, rev);
Map<String, Collection<String>> external = new HashMap<>();
for (DynamicMap.Entry<ExternalIncludedIn> i : includedIn) {
external.put(i.getExportName(),
@@ -96,7 +95,7 @@ class IncludedIn implements RestReadView<ChangeResource> {
Collection<String> tags;
Map<String, Collection<String>> external;
IncludedInInfo(IncludedInDetail in, Map<String, Collection<String>> e) {
IncludedInInfo(IncludedInResolver.Result in, Map<String, Collection<String>> e) {
branches = in.getBranches();
tags = in.getTags();
external = e;

View File

@@ -18,7 +18,6 @@ import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.collect.Sets;
import com.google.gerrit.common.data.IncludedInDetail;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
@@ -47,7 +46,7 @@ public class IncludedInResolver {
private static final Logger log = LoggerFactory
.getLogger(IncludedInResolver.class);
public static IncludedInDetail resolve(final Repository repo,
public static Result resolve(final Repository repo,
final RevWalk rw, final RevCommit commit) throws IOException {
RevFlag flag = newFlag(rw);
try {
@@ -87,7 +86,7 @@ public class IncludedInResolver {
this.containsTarget = containsTarget;
}
private IncludedInDetail resolve() throws IOException {
private Result resolve() throws IOException {
RefDatabase refDb = repo.getRefDatabase();
Collection<Ref> tags = refDb.getRefs(Constants.R_TAGS).values();
Collection<Ref> branches = refDb.getRefs(Constants.R_HEADS).values();
@@ -98,7 +97,7 @@ public class IncludedInResolver {
parseCommits(allTagsAndBranches);
Set<String> allMatchingTagsAndBranches = includedIn(tipsByCommitTime, 0);
IncludedInDetail detail = new IncludedInDetail();
Result detail = new Result();
detail
.setBranches(getMatchingRefNames(allMatchingTagsAndBranches, branches));
detail.setTags(getMatchingRefNames(allMatchingTagsAndBranches, tags));
@@ -228,4 +227,30 @@ public class IncludedInResolver {
}
});
}
public static class Result {
private List<String> branches;
private List<String> tags;
public Result() {
}
public void setBranches(final List<String> b) {
Collections.sort(b);
branches = b;
}
public List<String> getBranches() {
return branches;
}
public void setTags(final List<String> t) {
Collections.sort(t);
tags = t;
}
public List<String> getTags() {
return tags;
}
}
}