Skip to content

Commit aae72fd

Browse files
committed
refactor(Discovery): Make field param in GetAutocompletionOptions required
1 parent ec05ec5 commit aae72fd

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

discovery/src/main/java/com/ibm/watson/discovery/v1/Discovery.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,12 +1545,10 @@ public ServiceCall<Completions> getAutocompletion(GetAutocompletionOptions getAu
15451545
builder.header(header.getKey(), header.getValue());
15461546
}
15471547
builder.header("Accept", "application/json");
1548+
builder.query("prefix", getAutocompletionOptions.prefix());
15481549
if (getAutocompletionOptions.field() != null) {
15491550
builder.query("field", getAutocompletionOptions.field());
15501551
}
1551-
if (getAutocompletionOptions.prefix() != null) {
1552-
builder.query("prefix", getAutocompletionOptions.prefix());
1553-
}
15541552
if (getAutocompletionOptions.count() != null) {
15551553
builder.query("count", String.valueOf(getAutocompletionOptions.count()));
15561554
}

discovery/src/main/java/com/ibm/watson/discovery/v1/model/GetAutocompletionOptions.java

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ public class GetAutocompletionOptions extends GenericModel {
2121

2222
private String environmentId;
2323
private String collectionId;
24-
private String field;
2524
private String prefix;
25+
private String field;
2626
private Long count;
2727

2828
/**
@@ -31,15 +31,15 @@ public class GetAutocompletionOptions extends GenericModel {
3131
public static class Builder {
3232
private String environmentId;
3333
private String collectionId;
34-
private String field;
3534
private String prefix;
35+
private String field;
3636
private Long count;
3737

3838
private Builder(GetAutocompletionOptions getAutocompletionOptions) {
3939
this.environmentId = getAutocompletionOptions.environmentId;
4040
this.collectionId = getAutocompletionOptions.collectionId;
41-
this.field = getAutocompletionOptions.field;
4241
this.prefix = getAutocompletionOptions.prefix;
42+
this.field = getAutocompletionOptions.field;
4343
this.count = getAutocompletionOptions.count;
4444
}
4545

@@ -54,10 +54,12 @@ public Builder() {
5454
*
5555
* @param environmentId the environmentId
5656
* @param collectionId the collectionId
57+
* @param prefix the prefix
5758
*/
58-
public Builder(String environmentId, String collectionId) {
59+
public Builder(String environmentId, String collectionId, String prefix) {
5960
this.environmentId = environmentId;
6061
this.collectionId = collectionId;
62+
this.prefix = prefix;
6163
}
6264

6365
/**
@@ -92,24 +94,24 @@ public Builder collectionId(String collectionId) {
9294
}
9395

9496
/**
95-
* Set the field.
97+
* Set the prefix.
9698
*
97-
* @param field the field
99+
* @param prefix the prefix
98100
* @return the GetAutocompletionOptions builder
99101
*/
100-
public Builder field(String field) {
101-
this.field = field;
102+
public Builder prefix(String prefix) {
103+
this.prefix = prefix;
102104
return this;
103105
}
104106

105107
/**
106-
* Set the prefix.
108+
* Set the field.
107109
*
108-
* @param prefix the prefix
110+
* @param field the field
109111
* @return the GetAutocompletionOptions builder
110112
*/
111-
public Builder prefix(String prefix) {
112-
this.prefix = prefix;
113+
public Builder field(String field) {
114+
this.field = field;
113115
return this;
114116
}
115117

@@ -130,10 +132,12 @@ private GetAutocompletionOptions(Builder builder) {
130132
"environmentId cannot be empty");
131133
com.ibm.cloud.sdk.core.util.Validator.notEmpty(builder.collectionId,
132134
"collectionId cannot be empty");
135+
com.ibm.cloud.sdk.core.util.Validator.notNull(builder.prefix,
136+
"prefix cannot be null");
133137
environmentId = builder.environmentId;
134138
collectionId = builder.collectionId;
135-
field = builder.field;
136139
prefix = builder.prefix;
140+
field = builder.field;
137141
count = builder.count;
138142
}
139143

@@ -168,17 +172,6 @@ public String collectionId() {
168172
return collectionId;
169173
}
170174

171-
/**
172-
* Gets the field.
173-
*
174-
* The field in the result documents that autocompletion suggestions are identified from.
175-
*
176-
* @return the field
177-
*/
178-
public String field() {
179-
return field;
180-
}
181-
182175
/**
183176
* Gets the prefix.
184177
*
@@ -191,6 +184,17 @@ public String prefix() {
191184
return prefix;
192185
}
193186

187+
/**
188+
* Gets the field.
189+
*
190+
* The field in the result documents that autocompletion suggestions are identified from.
191+
*
192+
* @return the field
193+
*/
194+
public String field() {
195+
return field;
196+
}
197+
194198
/**
195199
* Gets the count.
196200
*

0 commit comments

Comments
 (0)