public static Negation not(Predicate operand) { return new Negation(operand); }
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(); } else { if (negated) { return new Negation(predicate);
public static boolean isValidFeatureConjunctionOperand(Predicate operand) { return operand instanceof Negation && ((Negation) operand).getOperand() instanceof FeatureSet && isValidFeatureConjunctionOperand(((Negation) operand).getOperand()) || operand instanceof FeatureSet && ((FeatureSet) operand).getValues().size() == 1; }
private static String getFeatureSetKey(Predicate predicate) { if (predicate instanceof FeatureSet) { return ((FeatureSet) predicate).getKey(); } else { Negation negation = (Negation) predicate; return ((FeatureSet) negation.getOperand()).getKey(); } }
Predicate operand = ((Negation)predicate).getOperand(); operand = simplifySubTree(operand); if (isTrue(operand)) { return new BooleanPredicate(true); ((Negation) predicate).setOperand(operand);
public Negation notInSet(String... values) { return new Negation(new FeatureSet(key, values)); } }
out.setLong(NODE_TYPE, TYPE_NEGATION); out = out.setArray(CHILDREN); encode(((Negation)predicate).getOperand(), out.addObject()); } else if (predicate instanceof BooleanPredicate) { out.setLong(NODE_TYPE, ((BooleanPredicate)predicate).getValue() ? TYPE_TRUE : TYPE_FALSE);
public Negation notInRange(long fromInclusive, long toInclusive) { return new Negation(new FeatureRange(key, fromInclusive, toInclusive)); }
n = d; if (not != null) { n = new Negation(n); }
if (not != null) { n = new Negation(n); }
return new Negation(decode(in.field(CHILDREN).entry(0)));