Add Javadoc to clarify behavior of {Accounts|Changes|Groups}#withOptions

On these classes there are two withOptions methods with different
arguments. It is reasonable to expect that both methods behave the
same, and there are two of them only for convenience.

However this is not the case; the methods behave differently. The one
taking a varargs array of options appends the options to the existing
options, while the one taking a EnumSet replaces the existing options.

Add Javadoc on the methods to explicitly document the differences in
behavior.

Change-Id: I148c1595506ae43c35419eee99b1be7e265099b1
This commit is contained in:
David Pursehouse 2019-01-17 11:30:00 +09:00
parent 038473962e
commit 28f241aeb5
3 changed files with 9 additions and 0 deletions

View File

@ -166,16 +166,19 @@ public interface Accounts {
return this; return this;
} }
/** Set an option on the request, appending to existing options. */
public QueryRequest withOption(ListAccountsOption options) { public QueryRequest withOption(ListAccountsOption options) {
this.options.add(options); this.options.add(options);
return this; return this;
} }
/** Set options on the request, appending to existing options. */
public QueryRequest withOptions(ListAccountsOption... options) { public QueryRequest withOptions(ListAccountsOption... options) {
this.options.addAll(Arrays.asList(options)); this.options.addAll(Arrays.asList(options));
return this; return this;
} }
/** Set options on the request, replacing existing options. */
public QueryRequest withOptions(EnumSet<ListAccountsOption> options) { public QueryRequest withOptions(EnumSet<ListAccountsOption> options) {
this.options = options; this.options = options;
return this; return this;

View File

@ -94,16 +94,19 @@ public interface Changes {
return this; return this;
} }
/** Set an option on the request, appending to existing options. */
public QueryRequest withOption(ListChangesOption options) { public QueryRequest withOption(ListChangesOption options) {
this.options.add(options); this.options.add(options);
return this; return this;
} }
/** Set options on the request, appending to existing options. */
public QueryRequest withOptions(ListChangesOption... options) { public QueryRequest withOptions(ListChangesOption... options) {
this.options.addAll(Arrays.asList(options)); this.options.addAll(Arrays.asList(options));
return this; return this;
} }
/** Set options on the request, replacing existing options. */
public QueryRequest withOptions(EnumSet<ListChangesOption> options) { public QueryRequest withOptions(EnumSet<ListChangesOption> options) {
this.options = options; this.options = options;
return this; return this;

View File

@ -243,16 +243,19 @@ public interface Groups {
return this; return this;
} }
/** Set an option on the request, appending to existing options. */
public QueryRequest withOption(ListGroupsOption options) { public QueryRequest withOption(ListGroupsOption options) {
this.options.add(options); this.options.add(options);
return this; return this;
} }
/** Set options on the request, appending to existing options. */
public QueryRequest withOptions(ListGroupsOption... options) { public QueryRequest withOptions(ListGroupsOption... options) {
this.options.addAll(Arrays.asList(options)); this.options.addAll(Arrays.asList(options));
return this; return this;
} }
/** Set options on the request, replacing existing options. */
public QueryRequest withOptions(EnumSet<ListGroupsOption> options) { public QueryRequest withOptions(EnumSet<ListGroupsOption> options) {
this.options = options; this.options = options;
return this; return this;