Skip to content

Commit

Permalink
Restore AbstractBuilder to package-private scope
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwiseman committed Sep 17, 2024
1 parent 214ac20 commit 8ab119d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 14 deletions.
11 changes: 3 additions & 8 deletions src/main/java/org/kohsuke/github/AbstractBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<R, S> extends GitHubInteractiveObject {
abstract class AbstractBuilder<R, S> extends GitHubInteractiveObject implements GitHubRequestBuilderDone<R> {

@Nonnull
private final Class<R> returnType;
Expand Down Expand Up @@ -95,14 +95,9 @@ protected AbstractBuilder(@Nonnull Class<R> 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 {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/kohsuke/github/GHDiscussion.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<GHDiscussion> {
private Setter(@Nonnull GHDiscussion base) {
Expand All @@ -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<Updater> {
private Updater(@Nonnull GHDiscussion base) {
Expand All @@ -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<Creator> {

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/kohsuke/github/GHLabel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<GHLabel> {
Expand All @@ -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<Updater> {
Expand All @@ -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<Creator> {
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/org/kohsuke/github/GitHubRequestBuilderDone.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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.
* <p>
* Batching looks like this:
* </p>
*
* <pre>
* update().someName(value).otherName(value).done()
* </pre>
* <p>
* Single changes look like this:
* </p>
*
* <pre>
* set().someName(value);
* set().otherName(value);
* </pre>
*
* @author Liam Newman
* @param <R>
* Final return type built by this builder returned when {@link #done()}} is called.
*/
public interface GitHubRequestBuilderDone<R> {

/**
* 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
*/
R done() throws IOException;
}

0 comments on commit 8ab119d

Please sign in to comment.