io.sphere.sdk.search.RangeExpression Maven / Gradle / Ivy
package io.sphere.sdk.search;
import javax.annotation.Nullable;
import static io.sphere.sdk.utils.IterableUtils.toStream;
import static java.util.stream.Collectors.joining;
abstract class RangeExpression> extends SearchModelExpression {
private final Iterable extends Range> ranges;
RangeExpression(final SearchModel searchModel, final TypeSerializer typeSerializer, final Iterable extends Range> ranges, @Nullable final String alias) {
super(searchModel, typeSerializer, alias);
this.ranges = ranges;
}
@Override
protected String serializedValue() {
return ":range" + toRangeExpression(ranges);
}
/**
* Turns a group of ranges into an expression of the form "(e1 to e2),(e3 to e4),..."
* @return the generated range expression.
*/
private String toRangeExpression(Iterable extends Range> ranges) {
return toStream(ranges).map(r -> r.serialize(serializer())).filter(r -> !r.isEmpty()).collect(joining(","));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy