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

io.sphere.internal.facets.AttributeTermFacetBase Maven / Gradle / Ivy

There is a newer version: 0.72.1
Show newest version
package io.sphere.internal.facets;

import io.sphere.client.QueryParam;
import io.sphere.client.facets.TermFacet;
import io.sphere.client.model.SearchResult;
import io.sphere.client.model.facets.TermFacetItem;
import io.sphere.client.model.facets.TermFacetResult;

import static io.sphere.internal.util.ListUtil.*;

import java.util.List;

/** Provides implementation of getUrlParams for term facets (term facets behave essentially the same for any attribute type). */
public abstract class AttributeTermFacetBase extends FacetBase implements TermFacet {
    protected AttributeTermFacetBase(String attribute) {
        super(attribute);
    }

    @Override public List getUrlParams(TermFacetItem item) {
        return list(new QueryParam(queryParam, item.getValue()));
    }

    @Override public  TermFacetResult getResult(SearchResult searchResult) { return searchResult.getTermFacet(this); }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy