io.sphere.sdk.queries.SphereEnumerationQueryModelImpl Maven / Gradle / Ivy
package io.sphere.sdk.queries;
import io.sphere.sdk.models.SphereEnumeration;
import io.sphere.sdk.utils.IterableUtils;
import javax.annotation.Nullable;
import java.util.List;
import static io.sphere.sdk.queries.StringQuerySortingModel.normalize;
import static java.util.stream.Collectors.toList;
final class SphereEnumerationQueryModelImpl extends QueryModelImpl implements SphereEnumerationOptionalQueryModel {
public SphereEnumerationQueryModelImpl(@Nullable final QueryModel parent, @Nullable final String pathSegment) {
super(parent, pathSegment);
}
@Override
public QueryPredicate is(final E enumValue) {
return isPredicate(enumValue.toSphereName());
}
@Override
public QueryPredicate isIn(final Iterable args) {
return isInPredicate(toSphereNameList(args));
}
@Override
public QueryPredicate isNotIn(final Iterable args) {
return isNotInPredicate(toSphereNameList(args));
}
@Override
public QueryPredicate isNot(final E element) {
return isNotPredicate(element.toSphereName());
}
@Override
public QueryPredicate isNotPresent() {
return isNotPresentPredicate();
}
@Override
public QueryPredicate isPresent() {
return isPresentPredicate();
}
private List toSphereNameList(final Iterable args) {
return IterableUtils.toStream(args)
.map(e -> normalize(e.toSphereName()))
.collect(toList());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy