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

com.unbxd.client.search.response.Facets Maven / Gradle / Ivy

The newest version!
package com.unbxd.client.search.response;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: sourabh
 * Date: 08/07/14
 * Time: 11:01 AM
 * To change this template use File | Settings | File Templates.
 */
public class Facets {

    private List _facets;
    private Map _facetsMap;

    protected Facets(Map params){
        this._facets = new ArrayList();
        this._facetsMap = new HashMap();

        for(String field : params.keySet()){
            Map facetParams = (Map) params.get(field);
            String type = (String) facetParams.get("type");

            Facet facet = type.equals("facet_fields") ? new Facet(field, facetParams) : new RangeFacet(field, facetParams);
            this._facets.add(facet);
            this._facetsMap.put(field, facet);
        }
    }

    /**
     * @return List of {@link Facet}
     */
    public List getFacets(){
        return this._facets;
    }

    /**
     * @return Map of field - {@link Facet}
     */
    public Map getFacetsAsMap(){
        return this._facetsMap;
    }

    /**
     * @param facetName
     * @return Facet for given field name
     */
    public Facet getFacet(String facetName){
        return this._facetsMap.get(facetName);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy