Merge changes Ieda2c06c,I198f5941,I6b0d658d

* changes:
  RevisionApi: Convert some methods to default methods
  RevisionApi: Document that files(String) takes a nullable arg
  ChangeApi: Convert some methods to default methods
This commit is contained in:
David Pursehouse
2018-11-08 09:10:17 +00:00
committed by Gerrit Code Review
5 changed files with 88 additions and 262 deletions

View File

@@ -49,17 +49,21 @@ public interface ChangeApi {
* @return API for accessing the revision. * @return API for accessing the revision.
* @throws RestApiException if an error occurred. * @throws RestApiException if an error occurred.
*/ */
RevisionApi current() throws RestApiException; default RevisionApi current() throws RestApiException {
return revision("current");
}
/** /**
* Look up a revision of a change by number. * Look up a revision of a change by number.
* *
* @see #current() * @see #current()
*/ */
RevisionApi revision(int id) throws RestApiException; default RevisionApi revision(int id) throws RestApiException {
return revision(Integer.toString(id));
}
/** /**
* Look up a revision of a change by commit SHA-1. * Look up a revision of a change by commit SHA-1 or other supported revision string.
* *
* @see #current() * @see #current()
*/ */
@@ -79,15 +83,23 @@ public interface ChangeApi {
*/ */
ReviewerApi reviewer(String id) throws RestApiException; ReviewerApi reviewer(String id) throws RestApiException;
void abandon() throws RestApiException; default void abandon() throws RestApiException {
abandon(new AbandonInput());
}
void abandon(AbandonInput in) throws RestApiException; void abandon(AbandonInput in) throws RestApiException;
void restore() throws RestApiException; default void restore() throws RestApiException {
restore(new RestoreInput());
}
void restore(RestoreInput in) throws RestApiException; void restore(RestoreInput in) throws RestApiException;
void move(String destination) throws RestApiException; default void move(String destination) throws RestApiException {
MoveInput in = new MoveInput();
in.destinationBranch = destination;
move(in);
}
void move(MoveInput in) throws RestApiException; void move(MoveInput in) throws RestApiException;
@@ -132,7 +144,9 @@ public interface ChangeApi {
* *
* @see Changes#id(int) * @see Changes#id(int)
*/ */
ChangeApi revert() throws RestApiException; default ChangeApi revert() throws RestApiException {
return revert(new RevertInput());
}
/** /**
* Create a new change that reverts this change. * Create a new change that reverts this change.
@@ -144,10 +158,17 @@ public interface ChangeApi {
/** Create a merge patch set for the change. */ /** Create a merge patch set for the change. */
ChangeInfo createMergePatchSet(MergePatchSetInput in) throws RestApiException; ChangeInfo createMergePatchSet(MergePatchSetInput in) throws RestApiException;
List<ChangeInfo> submittedTogether() throws RestApiException; default List<ChangeInfo> submittedTogether() throws RestApiException {
SubmittedTogetherInfo info =
submittedTogether(
EnumSet.noneOf(ListChangesOption.class), EnumSet.noneOf(SubmittedTogetherOption.class));
return info.changes;
}
SubmittedTogetherInfo submittedTogether(EnumSet<SubmittedTogetherOption> options) default SubmittedTogetherInfo submittedTogether(EnumSet<SubmittedTogetherOption> options)
throws RestApiException; throws RestApiException {
return submittedTogether(EnumSet.noneOf(ListChangesOption.class), options);
}
SubmittedTogetherInfo submittedTogether( SubmittedTogetherInfo submittedTogether(
EnumSet<ListChangesOption> listOptions, EnumSet<SubmittedTogetherOption> submitOptions) EnumSet<ListChangesOption> listOptions, EnumSet<SubmittedTogetherOption> submitOptions)
@@ -155,10 +176,14 @@ public interface ChangeApi {
/** Publishes a draft change. */ /** Publishes a draft change. */
@Deprecated @Deprecated
void publish() throws RestApiException; default void publish() throws RestApiException {
throw new UnsupportedOperationException("draft workflow is discontinued");
}
/** Rebase the current revision of a change using default options. */ /** Rebase the current revision of a change using default options. */
void rebase() throws RestApiException; default void rebase() throws RestApiException {
rebase(new RebaseInput());
}
/** Rebase the current revision of a change. */ /** Rebase the current revision of a change. */
void rebase(RebaseInput in) throws RestApiException; void rebase(RebaseInput in) throws RestApiException;
@@ -172,13 +197,19 @@ public interface ChangeApi {
IncludedInInfo includedIn() throws RestApiException; IncludedInInfo includedIn() throws RestApiException;
AddReviewerResult addReviewer(AddReviewerInput in) throws RestApiException; default AddReviewerResult addReviewer(String reviewer) throws RestApiException {
AddReviewerInput in = new AddReviewerInput();
in.reviewer = reviewer;
return addReviewer(in);
}
AddReviewerResult addReviewer(String in) throws RestApiException; AddReviewerResult addReviewer(AddReviewerInput in) throws RestApiException;
SuggestedReviewersRequest suggestReviewers() throws RestApiException; SuggestedReviewersRequest suggestReviewers() throws RestApiException;
SuggestedReviewersRequest suggestReviewers(String query) throws RestApiException; default SuggestedReviewersRequest suggestReviewers(String query) throws RestApiException {
return suggestReviewers().withQuery(query);
}
ChangeInfo get(EnumSet<ListChangesOption> options) throws RestApiException; ChangeInfo get(EnumSet<ListChangesOption> options) throws RestApiException;
@@ -198,10 +229,16 @@ public interface ChangeApi {
* <li>{@code SKIP_MERGEABLE} is omitted, so the {@code mergeable} bit <em>is</em> set. * <li>{@code SKIP_MERGEABLE} is omitted, so the {@code mergeable} bit <em>is</em> set.
* </ul> * </ul>
*/ */
ChangeInfo get() throws RestApiException; default ChangeInfo get() throws RestApiException {
return get(
EnumSet.complementOf(
EnumSet.of(ListChangesOption.CHECK, ListChangesOption.SKIP_MERGEABLE)));
}
/** {@link #get(ListChangesOption...)} with no options included. */ /** {@link #get(ListChangesOption...)} with no options included. */
ChangeInfo info() throws RestApiException; default ChangeInfo info() throws RestApiException {
return get(EnumSet.noneOf(ListChangesOption.class));
}
/** /**
* Retrieve change edit when exists. * Retrieve change edit when exists.
@@ -210,7 +247,9 @@ public interface ChangeApi {
* ChangeEditApi#get()}. * ChangeEditApi#get()}.
*/ */
@Deprecated @Deprecated
EditInfo getEdit() throws RestApiException; default EditInfo getEdit() throws RestApiException {
return edit().get().orElse(null);
}
/** /**
* Provides access to an API regarding the change edit of this change. * Provides access to an API regarding the change edit of this change.
@@ -221,7 +260,11 @@ public interface ChangeApi {
ChangeEditApi edit() throws RestApiException; ChangeEditApi edit() throws RestApiException;
/** Create a new patch set with a new commit message. */ /** Create a new patch set with a new commit message. */
void setMessage(String message) throws RestApiException; default void setMessage(String message) throws RestApiException {
CommitMessageInput in = new CommitMessageInput();
in.message = message;
setMessage(in);
}
/** Create a new patch set with a new commit message. */ /** Create a new patch set with a new commit message. */
void setMessage(CommitMessageInput in) throws RestApiException; void setMessage(CommitMessageInput in) throws RestApiException;
@@ -346,16 +389,6 @@ public interface ChangeApi {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public RevisionApi current() throws RestApiException {
throw new NotImplementedException();
}
@Override
public RevisionApi revision(int id) throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public ReviewerApi reviewer(String id) throws RestApiException { public ReviewerApi reviewer(String id) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
@@ -366,31 +399,16 @@ public interface ChangeApi {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public void abandon() throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public void abandon(AbandonInput in) throws RestApiException { public void abandon(AbandonInput in) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public void restore() throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public void restore(RestoreInput in) throws RestApiException { public void restore(RestoreInput in) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public void move(String destination) throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public void move(MoveInput in) throws RestApiException { public void move(MoveInput in) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
@@ -411,27 +429,11 @@ public interface ChangeApi {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public ChangeApi revert() throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public ChangeApi revert(RevertInput in) throws RestApiException { public ChangeApi revert(RevertInput in) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public void publish() throws RestApiException {
throw new NotImplementedException();
}
@Deprecated
@Override
public void rebase() throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public void rebase(RebaseInput in) throws RestApiException { public void rebase(RebaseInput in) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
@@ -462,51 +464,21 @@ public interface ChangeApi {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public AddReviewerResult addReviewer(String in) throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public SuggestedReviewersRequest suggestReviewers() throws RestApiException { public SuggestedReviewersRequest suggestReviewers() throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public SuggestedReviewersRequest suggestReviewers(String query) throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public ChangeInfo get(EnumSet<ListChangesOption> options) throws RestApiException { public ChangeInfo get(EnumSet<ListChangesOption> options) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public ChangeInfo get() throws RestApiException {
throw new NotImplementedException();
}
@Override
public ChangeInfo info() throws RestApiException {
throw new NotImplementedException();
}
@Override
public void setMessage(String message) throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public void setMessage(CommitMessageInput in) throws RestApiException { public void setMessage(CommitMessageInput in) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public EditInfo getEdit() throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public ChangeEditApi edit() throws RestApiException { public ChangeEditApi edit() throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@@ -14,6 +14,7 @@
package com.google.gerrit.extensions.api.changes; package com.google.gerrit.extensions.api.changes;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.client.SubmitType; import com.google.gerrit.extensions.client.SubmitType;
import com.google.gerrit.extensions.common.ActionInfo; import com.google.gerrit.extensions.common.ActionInfo;
import com.google.gerrit.extensions.common.CherryPickChangeInfo; import com.google.gerrit.extensions.common.CherryPickChangeInfo;
@@ -34,7 +35,9 @@ import java.util.Set;
public interface RevisionApi { public interface RevisionApi {
@Deprecated @Deprecated
void delete() throws RestApiException; default void delete() throws RestApiException {
throw new UnsupportedOperationException("draft workflow is discontinued");
}
String description() throws RestApiException; String description() throws RestApiException;
@@ -42,22 +45,32 @@ public interface RevisionApi {
ReviewResult review(ReviewInput in) throws RestApiException; ReviewResult review(ReviewInput in) throws RestApiException;
void submit() throws RestApiException; default void submit() throws RestApiException {
SubmitInput in = new SubmitInput();
submit(in);
}
void submit(SubmitInput in) throws RestApiException; void submit(SubmitInput in) throws RestApiException;
BinaryResult submitPreview() throws RestApiException; default BinaryResult submitPreview() throws RestApiException {
return submitPreview("zip");
}
BinaryResult submitPreview(String format) throws RestApiException; BinaryResult submitPreview(String format) throws RestApiException;
@Deprecated @Deprecated
void publish() throws RestApiException; default void publish() throws RestApiException {
throw new UnsupportedOperationException("draft workflow is discontinued");
}
ChangeApi cherryPick(CherryPickInput in) throws RestApiException; ChangeApi cherryPick(CherryPickInput in) throws RestApiException;
CherryPickChangeInfo cherryPickAsInfo(CherryPickInput in) throws RestApiException; CherryPickChangeInfo cherryPickAsInfo(CherryPickInput in) throws RestApiException;
ChangeApi rebase() throws RestApiException; default ChangeApi rebase() throws RestApiException {
RebaseInput in = new RebaseInput();
return rebase(in);
}
ChangeApi rebase(RebaseInput in) throws RestApiException; ChangeApi rebase(RebaseInput in) throws RestApiException;
@@ -69,9 +82,11 @@ public interface RevisionApi {
Set<String> reviewed() throws RestApiException; Set<String> reviewed() throws RestApiException;
Map<String, FileInfo> files() throws RestApiException; default Map<String, FileInfo> files() throws RestApiException {
return files(null);
}
Map<String, FileInfo> files(String base) throws RestApiException; Map<String, FileInfo> files(@Nullable String base) throws RestApiException;
Map<String, FileInfo> files(int parentNum) throws RestApiException; Map<String, FileInfo> files(int parentNum) throws RestApiException;
@@ -165,33 +180,16 @@ public interface RevisionApi {
* interface. * interface.
*/ */
class NotImplemented implements RevisionApi { class NotImplemented implements RevisionApi {
@Deprecated
@Override
public void delete() throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public ReviewResult review(ReviewInput in) throws RestApiException { public ReviewResult review(ReviewInput in) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public void submit() throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public void submit(SubmitInput in) throws RestApiException { public void submit(SubmitInput in) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Deprecated
@Override
public void publish() throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public ChangeApi cherryPick(CherryPickInput in) throws RestApiException { public ChangeApi cherryPick(CherryPickInput in) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
@@ -202,11 +200,6 @@ public interface RevisionApi {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public ChangeApi rebase() throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public ChangeApi rebase(RebaseInput in) throws RestApiException { public ChangeApi rebase(RebaseInput in) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
@@ -252,11 +245,6 @@ public interface RevisionApi {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public Map<String, FileInfo> files() throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public List<String> queryFiles(String query) throws RestApiException { public List<String> queryFiles(String query) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();
@@ -347,11 +335,6 @@ public interface RevisionApi {
throw new NotImplementedException(); throw new NotImplementedException();
} }
@Override
public BinaryResult submitPreview() throws RestApiException {
throw new NotImplementedException();
}
@Override @Override
public BinaryResult submitPreview(String format) throws RestApiException { public BinaryResult submitPreview(String format) throws RestApiException {
throw new NotImplementedException(); throw new NotImplementedException();

View File

@@ -43,7 +43,6 @@ import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.ChangeMessageInfo; import com.google.gerrit.extensions.common.ChangeMessageInfo;
import com.google.gerrit.extensions.common.CommentInfo; import com.google.gerrit.extensions.common.CommentInfo;
import com.google.gerrit.extensions.common.CommitMessageInput; import com.google.gerrit.extensions.common.CommitMessageInput;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.Input; import com.google.gerrit.extensions.common.Input;
import com.google.gerrit.extensions.common.MergePatchSetInput; import com.google.gerrit.extensions.common.MergePatchSetInput;
import com.google.gerrit.extensions.common.PureRevertInfo; import com.google.gerrit.extensions.common.PureRevertInfo;
@@ -255,16 +254,6 @@ class ChangeApiImpl implements ChangeApi {
return Integer.toString(change.getId().get()); return Integer.toString(change.getId().get());
} }
@Override
public RevisionApi current() throws RestApiException {
return revision("current");
}
@Override
public RevisionApi revision(int id) throws RestApiException {
return revision(String.valueOf(id));
}
@Override @Override
public RevisionApi revision(String id) throws RestApiException { public RevisionApi revision(String id) throws RestApiException {
try { try {
@@ -283,11 +272,6 @@ class ChangeApiImpl implements ChangeApi {
} }
} }
@Override
public void abandon() throws RestApiException {
abandon(new AbandonInput());
}
@Override @Override
public void abandon(AbandonInput in) throws RestApiException { public void abandon(AbandonInput in) throws RestApiException {
try { try {
@@ -297,11 +281,6 @@ class ChangeApiImpl implements ChangeApi {
} }
} }
@Override
public void restore() throws RestApiException {
restore(new RestoreInput());
}
@Override @Override
public void restore(RestoreInput in) throws RestApiException { public void restore(RestoreInput in) throws RestApiException {
try { try {
@@ -311,13 +290,6 @@ class ChangeApiImpl implements ChangeApi {
} }
} }
@Override
public void move(String destination) throws RestApiException {
MoveInput in = new MoveInput();
in.destinationBranch = destination;
move(in);
}
@Override @Override
public void move(MoveInput in) throws RestApiException { public void move(MoveInput in) throws RestApiException {
try { try {
@@ -359,11 +331,6 @@ class ChangeApiImpl implements ChangeApi {
} }
} }
@Override
public ChangeApi revert() throws RestApiException {
return revert(new RevertInput());
}
@Override @Override
public ChangeApi revert(RevertInput in) throws RestApiException { public ChangeApi revert(RevertInput in) throws RestApiException {
try { try {
@@ -382,20 +349,6 @@ class ChangeApiImpl implements ChangeApi {
} }
} }
@Override
public List<ChangeInfo> submittedTogether() throws RestApiException {
SubmittedTogetherInfo info =
submittedTogether(
EnumSet.noneOf(ListChangesOption.class), EnumSet.noneOf(SubmittedTogetherOption.class));
return info.changes;
}
@Override
public SubmittedTogetherInfo submittedTogether(EnumSet<SubmittedTogetherOption> options)
throws RestApiException {
return submittedTogether(EnumSet.noneOf(ListChangesOption.class), options);
}
@Override @Override
public SubmittedTogetherInfo submittedTogether( public SubmittedTogetherInfo submittedTogether(
EnumSet<ListChangesOption> listOptions, EnumSet<SubmittedTogetherOption> submitOptions) EnumSet<ListChangesOption> listOptions, EnumSet<SubmittedTogetherOption> submitOptions)
@@ -411,17 +364,6 @@ class ChangeApiImpl implements ChangeApi {
} }
} }
@Deprecated
@Override
public void publish() throws RestApiException {
throw new UnsupportedOperationException("draft workflow is discontinued");
}
@Override
public void rebase() throws RestApiException {
rebase(new RebaseInput());
}
@Override @Override
public void rebase(RebaseInput in) throws RestApiException { public void rebase(RebaseInput in) throws RestApiException {
try { try {
@@ -465,13 +407,6 @@ class ChangeApiImpl implements ChangeApi {
} }
} }
@Override
public AddReviewerResult addReviewer(String reviewer) throws RestApiException {
AddReviewerInput in = new AddReviewerInput();
in.reviewer = reviewer;
return addReviewer(in);
}
@Override @Override
public AddReviewerResult addReviewer(AddReviewerInput in) throws RestApiException { public AddReviewerResult addReviewer(AddReviewerInput in) throws RestApiException {
try { try {
@@ -491,11 +426,6 @@ class ChangeApiImpl implements ChangeApi {
}; };
} }
@Override
public SuggestedReviewersRequest suggestReviewers(String query) throws RestApiException {
return suggestReviewers().withQuery(query);
}
private List<SuggestedReviewerInfo> suggestReviewers(SuggestedReviewersRequest r) private List<SuggestedReviewerInfo> suggestReviewers(SuggestedReviewersRequest r)
throws RestApiException { throws RestApiException {
try { try {
@@ -516,30 +446,11 @@ class ChangeApiImpl implements ChangeApi {
} }
} }
@Override
public ChangeInfo get() throws RestApiException {
return get(
EnumSet.complementOf(
EnumSet.of(ListChangesOption.CHECK, ListChangesOption.SKIP_MERGEABLE)));
}
@Override
public EditInfo getEdit() throws RestApiException {
return edit().get().orElse(null);
}
@Override @Override
public ChangeEditApi edit() throws RestApiException { public ChangeEditApi edit() throws RestApiException {
return changeEditApi.create(change); return changeEditApi.create(change);
} }
@Override
public void setMessage(String msg) throws RestApiException {
CommitMessageInput in = new CommitMessageInput();
in.message = msg;
setMessage(in);
}
@Override @Override
public void setMessage(CommitMessageInput in) throws RestApiException { public void setMessage(CommitMessageInput in) throws RestApiException {
try { try {
@@ -549,11 +460,6 @@ class ChangeApiImpl implements ChangeApi {
} }
} }
@Override
public ChangeInfo info() throws RestApiException {
return get(EnumSet.noneOf(ListChangesOption.class));
}
@Override @Override
public void setHashtags(HashtagsInput input) throws RestApiException { public void setHashtags(HashtagsInput input) throws RestApiException {
try { try {

View File

@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.gerrit.server.api.ApiUtil.asRestApiException; import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.api.changes.ChangeApi; import com.google.gerrit.extensions.api.changes.ChangeApi;
import com.google.gerrit.extensions.api.changes.Changes; import com.google.gerrit.extensions.api.changes.Changes;
import com.google.gerrit.extensions.api.changes.CherryPickInput; import com.google.gerrit.extensions.api.changes.CherryPickInput;
@@ -226,12 +227,6 @@ class RevisionApiImpl implements RevisionApi {
} }
} }
@Override
public void submit() throws RestApiException {
SubmitInput in = new SubmitInput();
submit(in);
}
@Override @Override
public void submit(SubmitInput in) throws RestApiException { public void submit(SubmitInput in) throws RestApiException {
try { try {
@@ -241,11 +236,6 @@ class RevisionApiImpl implements RevisionApi {
} }
} }
@Override
public BinaryResult submitPreview() throws RestApiException {
return submitPreview("zip");
}
@Override @Override
public BinaryResult submitPreview(String format) throws RestApiException { public BinaryResult submitPreview(String format) throws RestApiException {
try { try {
@@ -256,22 +246,6 @@ class RevisionApiImpl implements RevisionApi {
} }
} }
@Override
public void publish() throws RestApiException {
throw new UnsupportedOperationException("draft workflow is discontinued");
}
@Override
public void delete() throws RestApiException {
throw new UnsupportedOperationException("draft workflow is discontinued");
}
@Override
public ChangeApi rebase() throws RestApiException {
RebaseInput in = new RebaseInput();
return rebase(in);
}
@Override @Override
public ChangeApi rebase(RebaseInput in) throws RestApiException { public ChangeApi rebase(RebaseInput in) throws RestApiException {
try { try {
@@ -366,17 +340,7 @@ class RevisionApiImpl implements RevisionApi {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public Map<String, FileInfo> files() throws RestApiException { public Map<String, FileInfo> files(@Nullable String base) throws RestApiException {
try {
return (Map<String, FileInfo>) listFiles.apply(revision).value();
} catch (Exception e) {
throw asRestApiException("Cannot retrieve files", e);
}
}
@SuppressWarnings("unchecked")
@Override
public Map<String, FileInfo> files(String base) throws RestApiException {
try { try {
return (Map<String, FileInfo>) listFiles.setBase(base).apply(revision).value(); return (Map<String, FileInfo>) listFiles.setBase(base).apply(revision).value();
} catch (Exception e) { } catch (Exception e) {

View File

@@ -18,6 +18,7 @@ import com.google.common.collect.Lists;
import com.google.common.flogger.FluentLogger; import com.google.common.flogger.FluentLogger;
import com.google.common.hash.Hasher; import com.google.common.hash.Hasher;
import com.google.common.hash.Hashing; import com.google.common.hash.Hashing;
import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.common.FileInfo; import com.google.gerrit.extensions.common.FileInfo;
import com.google.gerrit.extensions.registration.DynamicMap; import com.google.gerrit.extensions.registration.DynamicMap;
import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.AuthException;
@@ -332,7 +333,7 @@ public class Files implements ChildCollection<RevisionResource, FileResource> {
return this; return this;
} }
public ListFiles setBase(String base) { public ListFiles setBase(@Nullable String base) {
this.base = base; this.base = base;
return this; return this;
} }