Java 类org.hibernate.search.query.facet.FacetSortOrder 实例源码

项目:webdsl    文件:WebDSLFacetTool.java   
public static <T> FacetingRequest toFacetingRequest(String field, String rangeAsString, Class<?> entityClass, Class<T> type, FullTextSession fts){

        List<FacetRange<T>> facetRangeList = new ArrayList<FacetRange<T>>();
        DocumentBuilderIndexedEntity<?> documentBuilder = ContextHelper.getSearchFactory(fts).getDocumentBuilderIndexedEntity(entityClass);
        Matcher matcher = p.matcher( rangeAsString );
        FacetRange<T> range;
        T min, max;
        Class<?> targetClass;

        boolean includeMin, includeMax;
        while(matcher.find()){
            includeMin = matcher.group(1).equals("[");
            min = ( matcher.group( 2 ).isEmpty() ) ? null : (T) stringToTypedObject( matcher.group( 2 ).trim(), type );
            max = ( matcher.group( 3 ).isEmpty() ) ? null : (T) stringToTypedObject( matcher.group( 3 ).trim(), type );
            includeMax = matcher.group(4).equals("]");
            targetClass = (min != null) ? min.getClass() : max.getClass();

            range = new FacetRange<T>( targetClass, min, max, includeMin, includeMax, field, documentBuilder );
            facetRangeList.add(range);
        }
        FacetingRequestImpl rfr = new RangeFacetRequest<T>( facetName(field), field, facetRangeList, documentBuilder );
        rfr.setSort( FacetSortOrder.RANGE_DEFINITION_ODER );
        rfr.setIncludeZeroCounts( false );
        rfr.setMaxNumberOfFacets( facetRangeList.size() );

        return rfr;
    }