Skip to content
This repository was archived by the owner on Jan 31, 2022. It is now read-only.

Commit bb75de8

Browse files
committed
fix(Query): Reimplement missing overloads for arguments as List
1 parent 47297f8 commit bb75de8

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

algoliasearch/src/main/java/com/algolia/search/saas/Query.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,14 @@ public Integer getAroundRadius() {
250250

251251
private static final String KEY_ATTRIBUTES_TO_HIGHLIGHT = "attributesToHighlight";
252252

253+
/**
254+
* Deprecated, use {@link #setAttributesToHighlight(String...)}
255+
*/
256+
@Deprecated
257+
public @NonNull Query setAttributesToHighlight(List<String> attributes) {
258+
return set(KEY_ATTRIBUTES_TO_HIGHLIGHT, buildJSONArray((String[]) attributes.toArray()));
259+
}
260+
253261
/**
254262
* Specify the list of attribute names to highlight. By default indexed
255263
* attributes are highlighted.
@@ -265,6 +273,14 @@ public String[] getAttributesToHighlight() {
265273
private static final String KEY_ATTRIBUTES_TO_RETRIEVE = "attributesToRetrieve";
266274
private static final String KEY_ATTRIBUTES_TO_RETRIEVE_LEGACY = "attributes";
267275

276+
/**
277+
* Deprecated, use {@link #setAttributesToRetrieve(String...)}
278+
*/
279+
@Deprecated
280+
public @NonNull Query setAttributesToRetrieve(List<String> attributes) {
281+
return set(KEY_ATTRIBUTES_TO_RETRIEVE, buildJSONArray((String[]) attributes.toArray()));
282+
}
283+
268284
/**
269285
* Specify the list of attribute names to retrieve. By default all
270286
* attributes are retrieved.

algoliasearch/src/test/java/com/algolia/search/saas/QueryTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import java.io.UnsupportedEncodingException;
3131
import java.net.URLEncoder;
3232
import java.util.ArrayList;
33+
import java.util.Arrays;
3334
import java.util.List;
3435

3536
import static junit.framework.Assert.assertFalse;
@@ -295,6 +296,11 @@ public void attributesToHighlight() {
295296
assertArrayEquals(new String[]{ "foo", "bar" }, query.getAttributesToHighlight());
296297
assertEquals("[\"foo\",\"bar\"]", query.get("attributesToHighlight"));
297298
assertArrayEquals(query.getAttributesToHighlight(), Query.parse(query.build()).getAttributesToHighlight());
299+
300+
query.setAttributesToHighlight(Arrays.asList("foo", "bar"));
301+
assertArrayEquals(new String[]{ "foo", "bar" }, query.getAttributesToHighlight());
302+
assertEquals("[\"foo\",\"bar\"]", query.get("attributesToHighlight"));
303+
assertArrayEquals(query.getAttributesToHighlight(), Query.parse(query.build()).getAttributesToHighlight());
298304
}
299305

300306
@Test
@@ -305,6 +311,11 @@ public void attributesToRetrieve() {
305311
assertArrayEquals(new String[]{ "foo", "bar" }, query.getAttributesToRetrieve());
306312
assertEquals("[\"foo\",\"bar\"]", query.get("attributesToRetrieve"));
307313
assertArrayEquals(query.getAttributesToRetrieve(), Query.parse(query.build()).getAttributesToRetrieve());
314+
315+
query.setAttributesToRetrieve(Arrays.asList("foo", "bar"));
316+
assertArrayEquals(new String[]{ "foo", "bar" }, query.getAttributesToRetrieve());
317+
assertEquals("[\"foo\",\"bar\"]", query.get("attributesToRetrieve"));
318+
assertArrayEquals(query.getAttributesToRetrieve(), Query.parse(query.build()).getAttributesToRetrieve());
308319
}
309320

310321
@Test

0 commit comments

Comments
 (0)