Java Code Examples for cz.jirutka.rsql.parser.ast.LogicalNode

The following examples show how to use cz.jirutka.rsql.parser.ast.LogicalNode. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: tutorials   Source File: GenericRsqlSpecBuilder.java    License: MIT License 6 votes vote down vote up
public Specification<T> createSpecification(final LogicalNode logicalNode) {
    
    List<Specification<T>> specs = logicalNode.getChildren()
            .stream()
            .map(node -> createSpecification(node))
            .filter(Objects::nonNull)
            .collect(Collectors.toList());
    
    Specification<T> result = specs.get(0);
    if (logicalNode.getOperator() == LogicalOperator.AND) {
       for (int i = 1; i < specs.size(); i++) {
           result = Specification.where(result).and(specs.get(i));
       }
    }
    else if (logicalNode.getOperator() == LogicalOperator.OR) {
       for (int i = 1; i < specs.size(); i++) {
           result = Specification.where(result).or(specs.get(i));
       }
    }
    
    return result;
}
 
Example 2
Source Project: hawkbit   Source File: RSQLUtility.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private List<Predicate> acceptChilds(final LogicalNode node) {
    final List<Node> children = node.getChildren();
    final List<Predicate> childs = new ArrayList<>();
    for (final Node node2 : children) {
        final List<Predicate> accept = node2.accept(this);
        if (!CollectionUtils.isEmpty(accept)) {
            childs.addAll(accept);
        } else {
            LOGGER.debug("visit logical node children but could not parse it, ignoring {}", node2);
        }
    }
    return childs;
}
 
Example 3
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 5 votes vote down vote up
public T visit(Node node) {
    // remember overloading is chosen based on static type.
    if (node instanceof LogicalNode) {
        return visit((LogicalNode) node);
    } else if (node instanceof ComparisonNode) {
        return visit((ComparisonNode) node);
    } else {
        throw new UnsupportedOperationException("Did you invent 3rd type of the node?");
    }
}
 
Example 4
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 5 votes vote down vote up
public T visit(Node node) {
    // remember overloading is chosen based on static type.
    if (node instanceof LogicalNode) {
        return visit((LogicalNode) node);
    } else if (node instanceof ComparisonNode) {
        return visit((ComparisonNode) node);
    } else {
        throw new UnsupportedOperationException("Did you invent 3rd type of the node?");
    }
}
 
Example 5
Source Project: tutorials   Source File: GenericRsqlSpecBuilder.java    License: MIT License 5 votes vote down vote up
public Specification<T> createSpecification(final Node node) {
    if (node instanceof LogicalNode) {
        return createSpecification((LogicalNode) node);
    }
    if (node instanceof ComparisonNode) {
        return createSpecification((ComparisonNode) node);
    }
    return null;
}
 
Example 6
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public T visit(AndNode node) {
    return visit((LogicalNode) node);
}
 
Example 7
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public T visit(OrNode node) {
    return visit((LogicalNode) node);
}
 
Example 8
Source Project: pnc   Source File: SortRSQLNodeTraveller.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public SortInfo visit(LogicalNode logicalNode) {
    return null;
}
 
Example 9
Source Project: pnc   Source File: ComparatorRSQLNodeTraveller.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Comparator<DTO> visit(LogicalNode logicalNode) {
    return null;
}
 
Example 10
Source Project: pnc   Source File: EntityRSQLNodeTraveller.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public javax.persistence.criteria.Predicate visit(LogicalNode node) {
    logger.trace("Parsing LogicalNode {}", node);
    return proceedEmbeddedNodes(node);
}
 
Example 11
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public T visit(AndNode node) {
    return visit((LogicalNode) node);
}
 
Example 12
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public T visit(OrNode node) {
    return visit((LogicalNode) node);
}
 
Example 13
private Query visit(LogicalNode node, Operator operator) {
  List<Query> subQueries =
      node.getChildren().stream().map(childNode -> childNode.accept(this)).collect(toList());
  return Query.builder().setOperator(operator).setValue(subQueries).build();
}
 
Example 14
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 votes vote down vote up
public abstract T visit(LogicalNode logicalNode); 
Example 15
Source Project: pnc   Source File: RSQLNodeTraveller.java    License: Apache License 2.0 votes vote down vote up
public abstract T visit(LogicalNode logicalNode);