RevisionApi: Convert some methods to default methods
Change-Id: Ieda2c06c5fc81ef60c199ac2fc55474537e704a6
diff --git a/java/com/google/gerrit/extensions/api/changes/RevisionApi.java b/java/com/google/gerrit/extensions/api/changes/RevisionApi.java
index 02ccb31..14dc589 100644
--- a/java/com/google/gerrit/extensions/api/changes/RevisionApi.java
+++ b/java/com/google/gerrit/extensions/api/changes/RevisionApi.java
@@ -35,7 +35,9 @@
public interface RevisionApi {
@Deprecated
- void delete() throws RestApiException;
+ default void delete() throws RestApiException {
+ throw new UnsupportedOperationException("draft workflow is discontinued");
+ }
String description() throws RestApiException;
@@ -43,22 +45,32 @@
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;
- BinaryResult submitPreview() throws RestApiException;
+ default BinaryResult submitPreview() throws RestApiException {
+ return submitPreview("zip");
+ }
BinaryResult submitPreview(String format) throws RestApiException;
@Deprecated
- void publish() throws RestApiException;
+ default void publish() throws RestApiException {
+ throw new UnsupportedOperationException("draft workflow is discontinued");
+ }
ChangeApi cherryPick(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;
@@ -70,7 +82,9 @@
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(@Nullable String base) throws RestApiException;
@@ -166,33 +180,16 @@
* interface.
*/
class NotImplemented implements RevisionApi {
- @Deprecated
- @Override
- public void delete() throws RestApiException {
- throw new NotImplementedException();
- }
-
@Override
public ReviewResult review(ReviewInput in) throws RestApiException {
throw new NotImplementedException();
}
@Override
- public void submit() throws RestApiException {
- throw new NotImplementedException();
- }
-
- @Override
public void submit(SubmitInput in) throws RestApiException {
throw new NotImplementedException();
}
- @Deprecated
- @Override
- public void publish() throws RestApiException {
- throw new NotImplementedException();
- }
-
@Override
public ChangeApi cherryPick(CherryPickInput in) throws RestApiException {
throw new NotImplementedException();
@@ -204,11 +201,6 @@
}
@Override
- public ChangeApi rebase() throws RestApiException {
- throw new NotImplementedException();
- }
-
- @Override
public ChangeApi rebase(RebaseInput in) throws RestApiException {
throw new NotImplementedException();
}
@@ -254,11 +246,6 @@
}
@Override
- public Map<String, FileInfo> files() throws RestApiException {
- throw new NotImplementedException();
- }
-
- @Override
public List<String> queryFiles(String query) throws RestApiException {
throw new NotImplementedException();
}
@@ -349,11 +336,6 @@
}
@Override
- public BinaryResult submitPreview() throws RestApiException {
- throw new NotImplementedException();
- }
-
- @Override
public BinaryResult submitPreview(String format) throws RestApiException {
throw new NotImplementedException();
}
diff --git a/java/com/google/gerrit/server/api/changes/RevisionApiImpl.java b/java/com/google/gerrit/server/api/changes/RevisionApiImpl.java
index 6952f55..f8a2ecb 100644
--- a/java/com/google/gerrit/server/api/changes/RevisionApiImpl.java
+++ b/java/com/google/gerrit/server/api/changes/RevisionApiImpl.java
@@ -228,12 +228,6 @@
}
@Override
- public void submit() throws RestApiException {
- SubmitInput in = new SubmitInput();
- submit(in);
- }
-
- @Override
public void submit(SubmitInput in) throws RestApiException {
try {
submit.apply(revision, in);
@@ -243,11 +237,6 @@
}
@Override
- public BinaryResult submitPreview() throws RestApiException {
- return submitPreview("zip");
- }
-
- @Override
public BinaryResult submitPreview(String format) throws RestApiException {
try {
submitPreview.setFormat(format);
@@ -258,22 +247,6 @@
}
@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
public ChangeApi rebase(RebaseInput in) throws RestApiException {
try {
return changes.id(rebase.apply(revision, in)._number);
@@ -365,11 +338,6 @@
}
}
- @Override
- public Map<String, FileInfo> files() throws RestApiException {
- return files(null);
- }
-
@SuppressWarnings("unchecked")
@Override
public Map<String, FileInfo> files(@Nullable String base) throws RestApiException {