All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.sphere.sdk.search.model.TermExpression Maven / Gradle / Ivy

There is a newer version: 1.0.0-M26
Show newest version
package io.sphere.sdk.search.model;

import javax.annotation.Nullable;
import java.util.function.Function;

import static io.sphere.sdk.utils.IterableUtils.toStream;
import static java.util.stream.Collectors.joining;

abstract class TermExpression extends SearchModelExpression {
    private final Iterable terms;

    TermExpression(final SearchModel searchModel, final Function typeSerializer, final Iterable terms, @Nullable final String alias) {
        super(searchModel, typeSerializer, alias);
        this.terms = terms;
    }

    /**
     * Turns a group of terms into an expression of the form ":term1,term2,..."
     * @return the generated term expression.
     */
    @Override
    public String value() {
        return ":" + toStream(terms)
                .map(t -> serializer().apply(t))
                .filter(t -> !t.isEmpty())
                .collect(joining(","));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy