@Override public String toString() { return "LogicalNode [name=" + name + ", type=" + type + ", children=" + getChildren() + "]"; }
@Override public void visit(final LogicalNode node) { checkNotNull(node, "logical node"); final LogicalNode.Type type = node.getType(); final ParameterPredicateVisitor childVisitor = new ParameterPredicateVisitor(criteriaFactory, fieldExprFactory); node.getChildren().forEach(child -> child.accept(childVisitor)); switch (type) { case AND: criteria.add(criteriaFactory.and(childVisitor.getCriteria())); break; case OR: criteria.add(criteriaFactory.or(childVisitor.getCriteria())); break; case NOT: criteria.add(criteriaFactory.nor(childVisitor.getCriteria())); break; default: throwUnknownType(type); } }
/** * Constructor. Creates a new node with the given type. * * @param type type of this logical node. * @param subNodes the Nodes to add directly as children. */ public LogicalNode(final Type type, final Collection<Node> subNodes) { super(); this.type = type; this.name = type.getName(); getChildren().addAll(subNodes); }