io.sphere.sdk.queries.IsInQueryPredicate Maven / Gradle / Ivy
package io.sphere.sdk.queries;
import java.util.StringJoiner;
import static io.sphere.sdk.utils.IterableUtils.requireNonEmpty;
class IsInQueryPredicate extends QueryModelQueryPredicate {
private final Iterable values;
/**
* Creates a predicate which is a shortcut for multiple or statements.
* @param queryModel the parent model
* @param values possible values to query for, if it is for Strings, the may need to be escaped concerning double quotes.
* @throws IllegalArgumentException if values is empty
*/
public IsInQueryPredicate(final QueryModel queryModel, final Iterable values) {
super(queryModel);
requireNonEmpty(values);//SPHERE.IO requires values not to be empty
this.values = values;
}
@Override
protected String render() {
final StringJoiner joiner = new StringJoiner(", ");
values.forEach(x -> joiner.add(x.toString()));
return " in (" + joiner.toString() + ")";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy