renren-common/src/main/java/io/renren/common/specification/filter/FilterParser.java
/**
     * generate Filter by tokenizer and values and add it to filters of their parent node
     *
     * @param tokenizer
     * @param values
     * @param filters
     */
generate Filter by tokenizer and values and add it to filters of their parent node
@param tokenizer
@param values
@param filters
generate Filter by tokenizer and values and add it to filters of their parent node @param tokenizer @param values @param filters
private static void addFilter(StringTokenizer tokenizer, String[] values, List<Filter> filters) {
        String next = tokenizer.nextToken();
        if(next.equals(OR) || next.equals(AND)){
            for (Filter filter : filters){
                if(filter instanceof LogicalFilter && Objects.equals(((LogicalFilter) filter).getLogic(), next)){
                    addFilter(tokenizer, values, ((LogicalFilter) filter).getFilters());
                    return;
                }
            }
            List<Filter> currentFilters = new ArrayList<>();
            Filter currentFilter = new LogicalFilter(next, currentFilters);
            filters.add(currentFilter);
            addFilter(tokenizer, values, currentFilters);
        } else {
            ComparisonFilter comparisonFilter = getComparisonFilter(next, tokenizer, values);
            if (comparisonFilter != null) {
                filters.add(comparisonFilter);
            }
        }
    }
private static void addFilter ( StringTokenizer tokenizer , String [ ] values , List < Filter > filters ) { String next = tokenizer . nextToken ( ) ; if ( next . equals ( OR ) || next . equals ( AND ) ) { for ( Filter filter : filters ) { if ( filter instanceof LogicalFilter && Objects . equals ( ( ( LogicalFilter ) filter ) . getLogic ( ) , next ) ) { addFilter ( tokenizer , values , ( ( LogicalFilter ) filter ) . getFilters ( ) ) ; return ; } } List < Filter > currentFilters = new ArrayList < > ( ) ; Filter currentFilter = new LogicalFilter ( next , currentFilters ) ; filters . add ( currentFilter ) ; addFilter ( tokenizer , values , currentFilters ) ; } else { ComparisonFilter comparisonFilter = getComparisonFilter ( next , tokenizer , values ) ; if ( comparisonFilter != null ) { filters . add ( comparisonFilter ) ; } } }
generate Filter by tokenizer and values and add it to filters of their parent node
 @param tokenizer
 @param values
 @param filters
generate Filter by tokenizer and values and add it to filters of their parent node @param tokenizer @param values @param filters
// Only parent node has logic operator // Otherwise it is a leaf node with expression // Check whether exist of this logic node // If not then create a new logic node