Skip to content

Commit

Permalink
Typed custructors from auto-gen layers (#12522)
Browse files Browse the repository at this point in the history
  • Loading branch information
sima-zhu authored Jun 26, 2020
1 parent b58ce02 commit 83a6538
Show file tree
Hide file tree
Showing 248 changed files with 3,600 additions and 1,209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1998,4 +1998,8 @@
<Class name="com.azure.search.documents.SearchAsyncClient" />
<Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" />
</Match>
<Match>
<Class name="~com\.azure\.search\.documents\.indexes\.implementation\.models\.(Suggester|SynonymMap)" />
<Bug pattern="IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN"/>
</Match>
</FindBugsFilter>
1 change: 1 addition & 0 deletions sdk/search/azure-search-documents/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Changed version to 11.0.0.
- Removed preview version `SearchClientOptions.ServiceVersion.V2019_05_06_Preview`
and added version `SearchClientOptions.ServiceVersion.V2020_06_30`.
- Added value constructors for required parameters.

## 1.0.0-beta.4 (2020-06-09)
- Split `SearchServiceClient` into two clients `SearchIndexClient`, `SearchIndexerClient`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -799,9 +799,7 @@ private static SearchRequest createSearchRequest(String searchText, SearchOption
*/
private static SuggestRequest createSuggestRequest(String searchText, String suggesterName,
SuggestOptions suggestOptions) {
SuggestRequest suggestRequest = new SuggestRequest()
.setSearchText(searchText)
.setSuggesterName(suggesterName);
SuggestRequest suggestRequest = new SuggestRequest(searchText, suggesterName);

if (suggestOptions != null) {
suggestRequest.setFilter(suggestOptions.getFilter())
Expand Down Expand Up @@ -840,9 +838,7 @@ private static SuggestRequest createSuggestRequest(String searchText, String sug
*/
private static AutocompleteRequest createAutoCompleteRequest(String searchText, String suggesterName,
AutocompleteOptions autocompleteOptions) {
AutocompleteRequest autoCompleteRequest = new AutocompleteRequest()
.setSearchText(searchText)
.setSuggesterName(suggesterName);
AutocompleteRequest autoCompleteRequest = new AutocompleteRequest(searchText, suggesterName);

if (autocompleteOptions != null) {
autoCompleteRequest.setFilter(autocompleteOptions.getFilter())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,19 @@ Mono<Response<AutocompleteResult>> autocompletePost(
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Long>> countWithResponseAsync(RequestOptions requestOptions, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getIndexName() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getIndexName() is required and cannot be null."));
}
if (requestOptions != null) {
requestOptions.validate();
}
final String accept = "application/json; odata.metadata=none";
UUID xMsClientRequestIdInternal = null;
if (requestOptions != null) {
Expand Down Expand Up @@ -255,6 +268,22 @@ public Mono<Response<Long>> countWithResponseAsync(RequestOptions requestOptions
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<SearchDocumentsResult>> searchGetWithResponseAsync(
String searchText, SearchOptions searchOptions, RequestOptions requestOptions, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getIndexName() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getIndexName() is required and cannot be null."));
}
if (searchOptions != null) {
searchOptions.validate();
}
if (requestOptions != null) {
requestOptions.validate();
}
final String accept = "application/json; odata.metadata=none";
Boolean includeTotalResultCountInternal = null;
if (searchOptions != null) {
Expand Down Expand Up @@ -393,6 +422,24 @@ public Mono<Response<SearchDocumentsResult>> searchGetWithResponseAsync(
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<SearchDocumentsResult>> searchPostWithResponseAsync(
SearchRequest searchRequest, RequestOptions requestOptions, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getIndexName() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getIndexName() is required and cannot be null."));
}
if (searchRequest == null) {
return Mono.error(new IllegalArgumentException("Parameter searchRequest is required and cannot be null."));
} else {
searchRequest.validate();
}
if (requestOptions != null) {
requestOptions.validate();
}
final String accept = "application/json; odata.metadata=none";
UUID xMsClientRequestIdInternal = null;
if (requestOptions != null) {
Expand Down Expand Up @@ -424,6 +471,22 @@ public Mono<Response<SearchDocumentsResult>> searchPostWithResponseAsync(
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<Object>> getWithResponseAsync(
String key, List<String> selectedFields, RequestOptions requestOptions, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getIndexName() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getIndexName() is required and cannot be null."));
}
if (key == null) {
return Mono.error(new IllegalArgumentException("Parameter key is required and cannot be null."));
}
if (requestOptions != null) {
requestOptions.validate();
}
final String accept = "application/json; odata.metadata=none";
UUID xMsClientRequestIdInternal = null;
if (requestOptions != null) {
Expand Down Expand Up @@ -465,6 +528,28 @@ public Mono<Response<SuggestDocumentsResult>> suggestGetWithResponseAsync(
SuggestOptions suggestOptions,
RequestOptions requestOptions,
Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getIndexName() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getIndexName() is required and cannot be null."));
}
if (searchText == null) {
return Mono.error(new IllegalArgumentException("Parameter searchText is required and cannot be null."));
}
if (suggesterName == null) {
return Mono.error(new IllegalArgumentException("Parameter suggesterName is required and cannot be null."));
}
if (suggestOptions != null) {
suggestOptions.validate();
}
if (requestOptions != null) {
requestOptions.validate();
}
final String accept = "application/json; odata.metadata=none";
String filterInternal = null;
if (suggestOptions != null) {
Expand Down Expand Up @@ -556,6 +641,24 @@ public Mono<Response<SuggestDocumentsResult>> suggestGetWithResponseAsync(
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<SuggestDocumentsResult>> suggestPostWithResponseAsync(
SuggestRequest suggestRequest, RequestOptions requestOptions, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getIndexName() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getIndexName() is required and cannot be null."));
}
if (suggestRequest == null) {
return Mono.error(new IllegalArgumentException("Parameter suggestRequest is required and cannot be null."));
} else {
suggestRequest.validate();
}
if (requestOptions != null) {
requestOptions.validate();
}
final String accept = "application/json; odata.metadata=none";
UUID xMsClientRequestIdInternal = null;
if (requestOptions != null) {
Expand Down Expand Up @@ -586,6 +689,24 @@ public Mono<Response<SuggestDocumentsResult>> suggestPostWithResponseAsync(
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<IndexDocumentsResult>> indexWithResponseAsync(
IndexBatch batch, RequestOptions requestOptions, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getIndexName() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getIndexName() is required and cannot be null."));
}
if (batch == null) {
return Mono.error(new IllegalArgumentException("Parameter batch is required and cannot be null."));
} else {
batch.validate();
}
if (requestOptions != null) {
requestOptions.validate();
}
final String accept = "application/json; odata.metadata=none";
UUID xMsClientRequestIdInternal = null;
if (requestOptions != null) {
Expand Down Expand Up @@ -623,6 +744,28 @@ public Mono<Response<AutocompleteResult>> autocompleteGetWithResponseAsync(
RequestOptions requestOptions,
AutocompleteOptions autocompleteOptions,
Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getIndexName() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getIndexName() is required and cannot be null."));
}
if (searchText == null) {
return Mono.error(new IllegalArgumentException("Parameter searchText is required and cannot be null."));
}
if (suggesterName == null) {
return Mono.error(new IllegalArgumentException("Parameter suggesterName is required and cannot be null."));
}
if (autocompleteOptions != null) {
autocompleteOptions.validate();
}
if (requestOptions != null) {
requestOptions.validate();
}
final String accept = "application/json; odata.metadata=none";
UUID xMsClientRequestIdInternal = null;
if (requestOptions != null) {
Expand Down Expand Up @@ -704,6 +847,25 @@ public Mono<Response<AutocompleteResult>> autocompleteGetWithResponseAsync(
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<AutocompleteResult>> autocompletePostWithResponseAsync(
AutocompleteRequest autocompleteRequest, RequestOptions requestOptions, Context context) {
if (this.client.getEndpoint() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getIndexName() == null) {
return Mono.error(
new IllegalArgumentException(
"Parameter this.client.getIndexName() is required and cannot be null."));
}
if (autocompleteRequest == null) {
return Mono.error(
new IllegalArgumentException("Parameter autocompleteRequest is required and cannot be null."));
} else {
autocompleteRequest.validate();
}
if (requestOptions != null) {
requestOptions.validate();
}
final String accept = "application/json; odata.metadata=none";
UUID xMsClientRequestIdInternal = null;
if (requestOptions != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static com.azure.search.documents.indexes.implementation.models.AnalyzeRe
return null;
}
com.azure.search.documents.indexes.implementation.models.AnalyzeRequest analyzeRequest =
new com.azure.search.documents.indexes.implementation.models.AnalyzeRequest();
new com.azure.search.documents.indexes.implementation.models.AnalyzeRequest(obj.getText());

if (obj.getCharFilters() != null) {
List<com.azure.search.documents.indexes.implementation.models.CharFilterName> charFilters =
Expand All @@ -81,14 +81,12 @@ public static com.azure.search.documents.indexes.implementation.models.AnalyzeRe
analyzeRequest.setTokenFilters(tokenFilters);
}

String text = obj.getText();
analyzeRequest.setText(text);

if (obj.getTokenizerName() != null) {
com.azure.search.documents.indexes.implementation.models.LexicalTokenizerName tokenizer =
LexicalTokenizerNameConverter.map(obj.getTokenizerName());
analyzeRequest.setTokenizer(tokenizer);
}
analyzeRequest.validate();
return analyzeRequest;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,9 @@ public static com.azure.search.documents.indexes.implementation.models.AnalyzedT
return null;
}
com.azure.search.documents.indexes.implementation.models.AnalyzedTokenInfo analyzedTokenInfo =
new com.azure.search.documents.indexes.implementation.models.AnalyzedTokenInfo();

int endOffset = obj.getEndOffset();
PrivateFieldAccessHelper.set(analyzedTokenInfo, "endOffset", endOffset);

int startOffset = obj.getStartOffset();
PrivateFieldAccessHelper.set(analyzedTokenInfo, "startOffset", startOffset);

int position = obj.getPosition();
PrivateFieldAccessHelper.set(analyzedTokenInfo, "position", position);

String token = obj.getToken();
PrivateFieldAccessHelper.set(analyzedTokenInfo, "token", token);
new com.azure.search.documents.indexes.implementation.models.AnalyzedTokenInfo(obj.getToken(),
obj.getStartOffset(), obj.getEndOffset(), obj.getPosition());
analyzedTokenInfo.validate();
return analyzedTokenInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ public static com.azure.search.documents.indexes.implementation.models.AsciiFold
return null;
}
com.azure.search.documents.indexes.implementation.models.AsciiFoldingTokenFilter asciiFoldingTokenFilter =
new com.azure.search.documents.indexes.implementation.models.AsciiFoldingTokenFilter();

String name = obj.getName();
asciiFoldingTokenFilter.setName(name);
new com.azure.search.documents.indexes.implementation.models.AsciiFoldingTokenFilter(obj.getName());

Boolean preserveOriginal = obj.isPreserveOriginal();
asciiFoldingTokenFilter.setPreserveOriginal(preserveOriginal);
asciiFoldingTokenFilter.validate();
return asciiFoldingTokenFilter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,9 @@ public static com.azure.search.documents.implementation.models.AutocompleteItem
return null;
}
com.azure.search.documents.implementation.models.AutocompleteItem autocompleteItem =
new com.azure.search.documents.implementation.models.AutocompleteItem();
new com.azure.search.documents.implementation.models.AutocompleteItem(obj.getText(), obj.getQueryPlusText());

String text = obj.getText();
PrivateFieldAccessHelper.set(autocompleteItem, "text", text);

String queryPlusText = obj.getQueryPlusText();
PrivateFieldAccessHelper.set(autocompleteItem, "queryPlusText", queryPlusText);
autocompleteItem.validate();
return autocompleteItem;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,16 @@ public static com.azure.search.documents.implementation.models.AutocompleteResul
if (obj == null) {
return null;
}

List<com.azure.search.documents.implementation.models.AutocompleteItem> results = obj.getResults() == null ?
null : obj.getResults().stream().map(AutocompleteItemConverter::map).collect(Collectors.toList());
com.azure.search.documents.implementation.models.AutocompleteResult autocompleteResult =
new com.azure.search.documents.implementation.models.AutocompleteResult();
new com.azure.search.documents.implementation.models.AutocompleteResult(results);

Double coverage = obj.getCoverage();
PrivateFieldAccessHelper.set(autocompleteResult, "coverage", coverage);

if (obj.getResults() != null) {
List<com.azure.search.documents.implementation.models.AutocompleteItem> results =
obj.getResults().stream().map(AutocompleteItemConverter::map).collect(Collectors.toList());
PrivateFieldAccessHelper.set(autocompleteResult, "results", results);
}
autocompleteResult.validate();
return autocompleteResult;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ public static com.azure.search.documents.indexes.implementation.models.CjkBigram
return null;
}
com.azure.search.documents.indexes.implementation.models.CjkBigramTokenFilter cjkBigramTokenFilter =
new com.azure.search.documents.indexes.implementation.models.CjkBigramTokenFilter();

String name = obj.getName();
cjkBigramTokenFilter.setName(name);
new com.azure.search.documents.indexes.implementation.models.CjkBigramTokenFilter(obj.getName());

Boolean outputUnigrams = obj.areOutputUnigrams();
cjkBigramTokenFilter.setOutputUnigrams(outputUnigrams);
Expand All @@ -60,6 +57,7 @@ public static com.azure.search.documents.indexes.implementation.models.CjkBigram
obj.getIgnoreScripts().stream().map(CjkBigramTokenFilterScriptsConverter::map).collect(Collectors.toList());
cjkBigramTokenFilter.setIgnoreScripts(ignoreScripts);
}
cjkBigramTokenFilter.validate();
return cjkBigramTokenFilter;
}

Expand Down
Loading

0 comments on commit 83a6538

Please sign in to comment.