public static Conjunction and(Predicate... operands) { return new Conjunction(operands); }
public Predicate simplifyTree(Predicate predicate) { if (predicate instanceof Disjunction) { Disjunction disjunction = (Disjunction) predicate; List<Predicate> newChildren = disjunction.getOperands().stream().map(this::simplifyTree).collect(toList()); return compressFeatureSets(newChildren); } else if (predicate instanceof Negation) { Negation negation = (Negation) predicate; negation.setOperand(simplifyTree(negation.getOperand())); return negation; } else if (predicate instanceof Conjunction) { Conjunction conjunction = (Conjunction) predicate; List<Predicate> newChildren = conjunction.getOperands().stream().map(this::simplifyTree).collect(toList()); conjunction.setOperands(newChildren); return conjunction; } else { return predicate; } }
return simplifySubTree(((Negation) predicate).getOperand(), !negated); } else if (predicate instanceof Conjunction) { List<Predicate> in = ((Conjunction)predicate).getOperands(); List<Predicate> out = new ArrayList<>(in.size()); for (Predicate operand : in) { operand = simplifySubTree(operand, negated); if (operand instanceof Conjunction) { out.addAll(((Conjunction)operand).getOperands()); } else { out.add(operand); return new Disjunction(out); ((Conjunction)predicate).setOperands(out); } else if (predicate instanceof Disjunction) { List<Predicate> in = ((Disjunction)predicate).getOperands(); return new Conjunction(out);
state._fsp--; n = new Conjunction(n, u2); state._fsp--; ((Conjunction)n).addOperand(u3);
return new BooleanPredicate(true); ((Conjunction)predicate).setOperands(out); } else if (predicate instanceof Disjunction) { List<Predicate> in = ((PredicateOperator)predicate).getOperands();
out.setLong(NODE_TYPE, TYPE_CONJUNCTION); out = out.setArray(CHILDREN); for (Predicate operand : ((Conjunction)predicate).getOperands()) { encode(operand, out.addObject());
private static Predicate decode(Inspector in) { switch ((int)in.field(NODE_TYPE).asLong()) { case TYPE_CONJUNCTION: Conjunction conjunction = new Conjunction(); in = in.field(CHILDREN); for (int i = 0, len = in.children(); i < len; ++i) { conjunction.addOperand(decode(in.entry(i)));
List<Predicate> in = ((Conjunction)predicate).getOperands(); List<Predicate> out = new ArrayList<>(in.size()); List<Predicate> positiveChildren = new ArrayList<>(in.size()); ((Conjunction)predicate).setOperands(out); return positiveChildren.isEmpty(); } else if (predicate instanceof Disjunction) {