Skip to content

Commit 8e2d96a

Browse files
committed
add javadoc and alternatives
1 parent 408f44a commit 8e2d96a

File tree

3 files changed

+98
-18
lines changed

3 files changed

+98
-18
lines changed

clients/algoliasearch-client-java-2/algoliasearch-core/src/main/java/com/algolia/utils/AlgoliaIterableHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public Iterator<T> iterator() {
1616

1717
@Override
1818
public boolean hasNext() {
19-
if(isFirstRequest || (_hasNext.getAsBoolean() && !currentIterator.hasNext())) {
19+
if (isFirstRequest || (_hasNext.getAsBoolean() && !currentIterator.hasNext())) {
2020
currentIterator = executeQuery.get();
2121
isFirstRequest = false;
2222
}
@@ -25,7 +25,7 @@ public boolean hasNext() {
2525

2626
@Override
2727
public T next() {
28-
if(currentIterator == null || !currentIterator.hasNext()) {
28+
if (currentIterator == null || !currentIterator.hasNext()) {
2929
currentIterator = executeQuery.get();
3030
isFirstRequest = false;
3131
}

templates/java/api.mustache

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import java.util.Map;
2828
import java.util.stream.Collectors;
2929
import java.util.stream.Stream;
3030
import java.util.concurrent.CompletableFuture;
31-
3231
{{#operations}}
3332
public class {{classname}} extends ApiClient {
3433
{{#hasRegionalHost}}
@@ -124,7 +123,7 @@ public class {{classname}} extends ApiClient {
124123
/**
125124
* {{{notes}}}{{#allParams}}
126125
* @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#vendorExtensions.x-is-generic}}
127-
* @param innerType The class held by the index, could be your custom class or {@link Object}{{/vendorExtensions.x-is-generic}}
126+
* @param innerType The class held by the index, could be your custom class or {@link Object}.{{/vendorExtensions.x-is-generic}}
128127
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
129128
* @return {{> return_type}}
130129
{{> api_javadoc}}
@@ -136,7 +135,7 @@ public class {{classname}} extends ApiClient {
136135
/**
137136
* {{{notes}}}{{#allParams}}
138137
* @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#vendorExtensions.x-is-generic}}
139-
* @param innerType The class held by the index, could be your custom class or {@link Object}{{/vendorExtensions.x-is-generic}}
138+
* @param innerType The class held by the index, could be your custom class or {@link Object}.{{/vendorExtensions.x-is-generic}}
140139
* @return {{> return_type}}
141140
{{> api_javadoc}}
142141
public {{> return_type}} {{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#vendorExtensions.x-is-generic}}, Class<T> innerType{{/vendorExtensions.x-is-generic}}) throws AlgoliaRuntimeException {
@@ -148,7 +147,7 @@ public class {{classname}} extends ApiClient {
148147
/**
149148
* {{{notes}}}{{#requiredParams}}
150149
* @param {{paramName}} {{{description}}} (required){{/requiredParams}}{{#vendorExtensions.x-is-generic}}
151-
* @param innerType The class held by the index, could be your custom class or {@link Object}{{/vendorExtensions.x-is-generic}}
150+
* @param innerType The class held by the index, could be your custom class or {@link Object}.{{/vendorExtensions.x-is-generic}}
152151
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
153152
* @return {{> return_type}}
154153
{{> api_javadoc}}
@@ -162,7 +161,7 @@ public class {{classname}} extends ApiClient {
162161
/**
163162
* {{{notes}}}{{#requiredParams}}
164163
* @param {{paramName}} {{{description}}} (required){{/requiredParams}}{{#vendorExtensions.x-is-generic}}
165-
* @param innerType The class held by the index, could be your custom class or {@link Object}{{/vendorExtensions.x-is-generic}}
164+
* @param innerType The class held by the index, could be your custom class or {@link Object}.{{/vendorExtensions.x-is-generic}}
166165
* @return {{> return_type}}
167166
{{> api_javadoc}}
168167
public {{> return_type}} {{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#vendorExtensions.x-is-generic}}, Class<T> innerType{{/vendorExtensions.x-is-generic}}) throws AlgoliaRuntimeException {
@@ -174,7 +173,7 @@ public class {{classname}} extends ApiClient {
174173
* (asynchronously)
175174
* {{notes}}{{#allParams}}
176175
* @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#vendorExtensions.x-is-generic}}
177-
* @param innerType The class held by the index, could be your custom class or {@link Object}{{/vendorExtensions.x-is-generic}}
176+
* @param innerType The class held by the index, could be your custom class or {@link Object}.{{/vendorExtensions.x-is-generic}}
178177
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
179178
* @return {{> return_type_async}} The awaitable future
180179
{{> api_javadoc}}
@@ -224,7 +223,7 @@ public class {{classname}} extends ApiClient {
224223
* (asynchronously)
225224
* {{notes}}{{#allParams}}
226225
* @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#vendorExtensions.x-is-generic}}
227-
* @param innerType The class held by the index, could be your custom class or {@link Object}{{/vendorExtensions.x-is-generic}}
226+
* @param innerType The class held by the index, could be your custom class or {@link Object}.{{/vendorExtensions.x-is-generic}}
228227
* @return {{> return_type_async}} The awaitable future
229228
{{> api_javadoc}}
230229
public {{> return_type_async}} {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#vendorExtensions.x-is-generic}}, Class<T> innerType{{/vendorExtensions.x-is-generic}}) throws AlgoliaRuntimeException {
@@ -237,7 +236,7 @@ public class {{classname}} extends ApiClient {
237236
* (asynchronously)
238237
* {{notes}}{{#requiredParams}}
239238
* @param {{paramName}} {{{description}}} (required){{/requiredParams}}{{#vendorExtensions.x-is-generic}}
240-
* @param innerType The class held by the index, could be your custom class or {@link Object}{{/vendorExtensions.x-is-generic}}
239+
* @param innerType The class held by the index, could be your custom class or {@link Object}.{{/vendorExtensions.x-is-generic}}
241240
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
242241
* @return {{> return_type_async}} The awaitable future
243242
{{> api_javadoc}}
@@ -252,7 +251,7 @@ public class {{classname}} extends ApiClient {
252251
* (asynchronously)
253252
* {{notes}}{{#requiredParams}}
254253
* @param {{paramName}} {{{description}}} (required){{/requiredParams}}{{#vendorExtensions.x-is-generic}}
255-
* @param innerType The class held by the index, could be your custom class or {@link Object}{{/vendorExtensions.x-is-generic}}
254+
* @param innerType The class held by the index, could be your custom class or {@link Object}.{{/vendorExtensions.x-is-generic}}
256255
* @return {{> return_type_async}} The awaitable future
257256
{{> api_javadoc}}
258257
public {{> return_type_async}} {{operationId}}Async({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}{{#vendorExtensions.x-is-generic}}, Class<T> innerType{{/vendorExtensions.x-is-generic}}) throws AlgoliaRuntimeException {

templates/java/api_helpers.mustache

Lines changed: 88 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,21 @@ public GetApiKeyResponse waitForApiKey(ApiKeyOperation operation, String key) {
224224
return this.waitForApiKey(operation, key, null, TaskUtils.DEFAULT_MAX_RETRIES, TaskUtils.DEFAULT_TIMEOUT, null);
225225
}
226226
227-
public <T> Iterable<T> browseObjects(String indexName, BrowseParams browseParams, Class<T> innerType) {
227+
/**
228+
* Helper: Returns an iterator on top of the `browse` method.
229+
*
230+
* @summary Returns an iterator on `browse`.
231+
* @param indexName The index in which to perform the request.
232+
* @param params The `browse` parameters.
233+
* @param innerType The class held by the index, could be your custom class or {@link Object}.
234+
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions. (optional)
235+
*/
236+
public <T> Iterable<T> browseObjects(String indexName, BrowseParamsObject params, Class<T> innerType, RequestOptions requestOptions) {
228237
final Holder<String> currentCursor = new Holder<>();
229-
final BrowseParamsObject params = (BrowseParamsObject)browseParams.getInsideValue();
230238
231239
return AlgoliaIterableHelper.createIterable(
232240
() -> {
233-
BrowseResponse<T> response = this.browse(indexName, BrowseParams.of(params), innerType);
241+
BrowseResponse<T> response = this.browse(indexName, BrowseParams.of(params), innerType, requestOptions);
234242
params.setCursor(response.getCursor());
235243
currentCursor.value = response.getCursor();
236244
return response.getHits().iterator();
@@ -241,13 +249,34 @@ public <T> Iterable<T> browseObjects(String indexName, BrowseParams browseParams
241249
);
242250
}
243251
244-
public Iterable<SynonymHit> browseSynonyms(String indexName) {
252+
/**
253+
* Helper: Returns an iterator on top of the `browse` method.
254+
*
255+
* @summary Returns an iterator on `browse`.
256+
* @param indexName The index in which to perform the request.
257+
* @param params The `browse` parameters.
258+
* @param innerType The class held by the index, could be your custom class or {@link Object}.
259+
*/
260+
public <T> Iterable<T> browseObjects(String indexName, BrowseParamsObject params, Class<T> innerType) {
261+
return browseObjects(indexName, params, innerType, null);
262+
}
263+
264+
/**
265+
* Helper: Returns an iterator on top of the `searchSynonyms` method.
266+
*
267+
* @summary Returns an iterator on `searchSynonyms`.
268+
* @param indexName The index in which to perform the request.
269+
* @param type The synonym type. (optional)
270+
* @param params The `searchSynonyms` parameters. (optional)
271+
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions. (optional)
272+
*/
273+
public Iterable<SynonymHit> browseSynonyms(String indexName, SynonymType type, SearchSynonymsParams params, RequestOptions requestOptions) {
245274
final Holder<Integer> currentPage = new Holder<>(0);
246275
final int hitsPerPage = 1000;
247276
248277
return AlgoliaIterableHelper.createIterable(
249278
() -> {
250-
SearchSynonymsResponse response = this.searchSynonyms(indexName, null, currentPage.value, hitsPerPage, null);
279+
SearchSynonymsResponse response = this.searchSynonyms(indexName, type, currentPage.value, hitsPerPage, params, requestOptions);
251280
currentPage.value = response.getNbHits() < hitsPerPage ? null : currentPage.value + 1;
252281
return response.getHits().iterator();
253282
},
@@ -257,14 +286,45 @@ public Iterable<SynonymHit> browseSynonyms(String indexName) {
257286
);
258287
}
259288
260-
public Iterable<Rule> browseRules(String indexName, SearchRulesParams params) {
289+
/**
290+
* Helper: Returns an iterator on top of the `searchSynonyms` method.
291+
*
292+
* @summary Returns an iterator on `searchSynonyms`.
293+
* @param indexName The index in which to perform the request.
294+
* @param type The synonym type. (optional)
295+
* @param params The `searchSynonyms` parameters .(optional)
296+
*/
297+
public Iterable<SynonymHit> browseSynonyms(String indexName, SynonymType type, SearchSynonymsParams params) {
298+
return browseSynonyms(indexName, type, params, null);
299+
}
300+
301+
302+
/**
303+
* Helper: Returns an iterator on top of the `searchSynonyms` method.
304+
*
305+
* @summary Returns an iterator on `searchSynonyms`.
306+
* @param indexName The index in which to perform the request.
307+
*/
308+
public Iterable<SynonymHit> browseSynonyms(String indexName) {
309+
return browseSynonyms(indexName, null, null, null);
310+
}
311+
312+
/**
313+
* Helper: Returns an iterator on top of the `searchRules` method.
314+
*
315+
* @summary Returns an iterator on `searchRules`.
316+
* @param indexName The index in which to perform the request.
317+
* @param params The `searchRules` parameters. (optional)
318+
* @param requestOptions The requestOptions to send along with the query, they will be merged with the transporter requestOptions. (optional)
319+
*/
320+
public Iterable<Rule> browseRules(String indexName, SearchRulesParams params, RequestOptions requestOptions) {
261321
final Holder<Integer> currentPage = new Holder<>(0);
262322
final int hitsPerPage = 1000;
263323
params.setHitsPerPage(hitsPerPage);
264324
265325
return AlgoliaIterableHelper.createIterable(
266326
() -> {
267-
SearchRulesResponse response = this.searchRules(indexName, params.setPage(currentPage.value));
327+
SearchRulesResponse response = this.searchRules(indexName, params.setPage(currentPage.value), requestOptions);
268328
currentPage.value = response.getNbHits() < hitsPerPage ? null : currentPage.value + 1;
269329
return response.getHits().iterator();
270330
},
@@ -273,4 +333,25 @@ public Iterable<Rule> browseRules(String indexName, SearchRulesParams params) {
273333
}
274334
);
275335
}
336+
337+
/**
338+
* Helper: Returns an iterator on top of the `searchRules` method.
339+
*
340+
* @summary Returns an iterator on `searchRules`.
341+
* @param indexName The index in which to perform the request.
342+
* @param params The `searchRules` parameters. (optional)
343+
*/
344+
public Iterable<Rule> browseRules(String indexName, SearchRulesParams params) {
345+
return browseRules(indexName, params, null);
346+
}
347+
348+
/**
349+
* Helper: Returns an iterator on top of the `searchRules` method.
350+
*
351+
* @summary Returns an iterator on `searchRules`.
352+
* @param indexName The index in which to perform the request.
353+
*/
354+
public Iterable<Rule> browseRules(String indexName) {
355+
return browseRules(indexName, null, null);
356+
}
276357
{{/isSearchClient}}

0 commit comments

Comments
 (0)