diff --git a/src/main/java/org/kohsuke/github/AbstractBuilder.java b/src/main/java/org/kohsuke/github/AbstractBuilder.java index 9df514af9..8a581270e 100644 --- a/src/main/java/org/kohsuke/github/AbstractBuilder.java +++ b/src/main/java/org/kohsuke/github/AbstractBuilder.java @@ -41,7 +41,7 @@ * Intermediate return type for this builder returned by calls to {@link #with(String, Object)}. If {@link S} * the same as {@link R}, this builder will commit changes after each call to {@link #with(String, Object)}. */ -public abstract class AbstractBuilder extends GitHubInteractiveObject { +abstract class AbstractBuilder extends GitHubInteractiveObject implements GitHubRequestBuilderDone { @Nonnull private final Class returnType; @@ -95,14 +95,9 @@ protected AbstractBuilder(@Nonnull Class finalReturnType, } /** - * Finishes an update, committing changes. - * - * This method may update-in-place or not. Either way it returns the resulting instance. - * - * @return an instance with updated current data - * @throws IOException - * if there is an I/O Exception + * {@inheritDoc} */ + @Override @Nonnull @BetaApi public R done() throws IOException { diff --git a/src/main/java/org/kohsuke/github/GHDiscussion.java b/src/main/java/org/kohsuke/github/GHDiscussion.java index 59e3fcbe7..94edaacbc 100644 --- a/src/main/java/org/kohsuke/github/GHDiscussion.java +++ b/src/main/java/org/kohsuke/github/GHDiscussion.java @@ -201,7 +201,7 @@ private static String getRawUrlPath(@Nonnull GHTeam team, @CheckForNull Long dis /** * A {@link GHLabelBuilder} that updates a single property per request * - * {@link #done()} is called automatically after the property is set. + * {@link GitHubRequestBuilderDone#done()} is called automatically after the property is set. */ public static class Setter extends GHDiscussionBuilder { private Setter(@Nonnull GHDiscussion base) { @@ -213,7 +213,7 @@ private Setter(@Nonnull GHDiscussion base) { /** * A {@link GHLabelBuilder} that allows multiple properties to be updated per request. * - * Consumer must call {@link #done()} to commit changes. + * Consumer must call {@link Updater#done()} to commit changes. */ public static class Updater extends GHDiscussionBuilder { private Updater(@Nonnull GHDiscussion base) { @@ -225,7 +225,7 @@ private Updater(@Nonnull GHDiscussion base) { /** * A {@link GHLabelBuilder} that creates a new {@link GHLabel} * - * Consumer must call {@link #done()} to create the new instance. + * Consumer must call {@link Creator#done()} to create the new instance. */ public static class Creator extends GHDiscussionBuilder { diff --git a/src/main/java/org/kohsuke/github/GHLabel.java b/src/main/java/org/kohsuke/github/GHLabel.java index fcc478693..6b77b8bfa 100644 --- a/src/main/java/org/kohsuke/github/GHLabel.java +++ b/src/main/java/org/kohsuke/github/GHLabel.java @@ -250,7 +250,7 @@ public int hashCode() { /** * A {@link GHLabelBuilder} that updates a single property per request * - * {@link #done()} is called automatically after the property is set. + * {@link Setter#done()} is called automatically after the property is set. */ @BetaApi public static class Setter extends GHLabelBuilder { @@ -263,7 +263,7 @@ private Setter(@Nonnull GHLabel base) { /** * A {@link GHLabelBuilder} that allows multiple properties to be updated per request. * - * Consumer must call {@link #done()} to commit changes. + * Consumer must call {@link Updater#done()} to commit changes. */ @BetaApi public static class Updater extends GHLabelBuilder { @@ -276,7 +276,7 @@ private Updater(@Nonnull GHLabel base) { /** * A {@link GHLabelBuilder} that creates a new {@link GHLabel} * - * Consumer must call {@link #done()} to create the new instance. + * Consumer must call {@link Creator#done()} to create the new instance. */ @BetaApi public static class Creator extends GHLabelBuilder { diff --git a/src/main/java/org/kohsuke/github/GitHubRequestBuilderDone.java b/src/main/java/org/kohsuke/github/GitHubRequestBuilderDone.java new file mode 100644 index 000000000..2ace9de44 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GitHubRequestBuilderDone.java @@ -0,0 +1,42 @@ +package org.kohsuke.github; + +import java.io.IOException; + +/** + * The done method for data object builder/updater. + * + * This interface can be used to make a Builder that supports both batch and single property changes. + *

+ * Batching looks like this: + *

+ * + *
+ * update().someName(value).otherName(value).done()
+ * 
+ *

+ * Single changes look like this: + *

+ * + *
+ * set().someName(value);
+ * set().otherName(value);
+ * 
+ * + * @author Liam Newman + * @param + * Final return type built by this builder returned when {@link #done()}} is called. + */ +public interface GitHubRequestBuilderDone { + + /** + * Finishes a create or update request, committing changes. + * + * This method may update-in-place or not. Either way it returns the resulting instance. + * + * @return an instance with updated current data + * @throws IOException + * if there is an I/O Exception + */ + @BetaApi + R done() throws IOException; +} diff --git a/src/test/resources/no-reflect-and-serialization-list b/src/test/resources/no-reflect-and-serialization-list index 705a18d5e..e1e4fa2e0 100644 --- a/src/test/resources/no-reflect-and-serialization-list +++ b/src/test/resources/no-reflect-and-serialization-list @@ -30,6 +30,7 @@ org.kohsuke.github.GitHubRateLimitChecker org.kohsuke.github.GitHubRateLimitHandler org.kohsuke.github.GitHubRateLimitHandler$1 org.kohsuke.github.GitHubRateLimitHandler$2 +org.kohsuke.github.GitHubRequestBuilderDone org.kohsuke.github.HttpConnector org.kohsuke.github.HttpException org.kohsuke.github.PagedIterator