예제 #1
0
 /**
  * Create negation of compound predicate by using logic rules: 1. not (x || y) is (not x && not y)
  * 2. not (x && y) is (not x || not y)
  */
 @Override
 public Predicate not() {
   toggleOperator();
   for (Expression expr : this.getExpressions()) {
     if (Predicate.class.isInstance(expr)) {
       ((Predicate) expr).not();
     }
   }
   return this;
 }
예제 #2
0
 @Override
 public Predicate isFalse(Expression<Boolean> expression) {
   if (CompoundPredicate.class.isInstance(expression)) {
     final CompoundPredicate predicate = (CompoundPredicate) expression;
     if (predicate.getExpressions().size() == 0) {
       return new BooleanStaticAssertionPredicate(
           this, predicate.getOperator() == Predicate.BooleanOperator.OR);
     }
     predicate.not();
     return predicate;
   } else if (Predicate.class.isInstance(expression)) {
     final Predicate predicate = (Predicate) expression;
     predicate.not();
     return predicate;
   }
   return new BooleanAssertionPredicate(this, expression, Boolean.FALSE);
 }