io.sphere.sdk.search.model.RangeExpression Maven / Gradle / Ivy
package io.sphere.sdk.search.model;
import javax.annotation.Nullable;
import java.util.function.Function;
import static io.sphere.sdk.utils.IterableUtils.requireNonEmpty;
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 Function typeSerializer, final Iterable extends Range> ranges, @Nullable final String alias) {
super(searchModel, typeSerializer, alias);
this.ranges = requireNonEmpty(ranges);
}
/**
* Turns a group of ranges into an expression of the form ":range(e1 to e2),(e3 to e4),..."
* @return the generated range expression.
*/
public String value() {
return ":range" + toStream(ranges)
.map(r -> r.serialize(serializer()))
.filter(r -> !r.isEmpty())
.collect(joining(","));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy