0
votes

Can anyone tell me how to 'in' clause with Hazelcast predicate. I want to use the following,

Predicates.in('column',value);

I want to pass the value as an ArrayList of values. But it is throwing error as it expects object that implements comparable. Is there any workaround for this?

1

1 Answers

0
votes

Predicates.in takes arguments of types (String, Comparable...).

So for the column name you pass a String as you have done. Comparable... means you can pass the individual values in a comma-separated list, but you can also pass them in an array. An ArrayList won't automatically be converted, but you can do it as follows:

ArrayList<String> values = new ArrayList<>(Arrays.asList("one", "two", "three");
Predicates.in("column", values.toArray(new String[]));

The (new String[]) argument is just to ensure you get back an array of Strings, otherwise you'll get an array of Objects.