LogicalConditions { public static <T extends UserContext> SendCondition<T> not(final SendCondition<T> condition) { return new SendCondition<T>() { @Override public boolean isApplicable(T userContext) { return !condition.isApplicable(userContext); } }; } private  LogicalConditions(); static SendCondition<T> and(final SendCondition<T> first, final SendCondition<T> second); static SendCondition<T> and(final SendCondition<T>... conditions); static SendCondition<T> or(final SendCondition<T> first, final SendCondition<T> second); static SendCondition<T> or(final SendCondition<T>... conditions); static SendCondition<T> not(final SendCondition<T> condition);  }
@Test public void testNotConditionFromPositiveToNegative() throws Exception { SendCondition<UserContext> acceptingCondition = createAcceptingCondition(); SendCondition<UserContext> orCondition = LogicalConditions.not(acceptingCondition); UserContext user = createUserContextObject(); boolean isApplicable = orCondition.isApplicable(user); assertFalse(isApplicable); }
@Test public void testNotConditionFromNegativeToPositive() throws Exception { SendCondition<UserContext> refusingCondition = createRefusingCondition(); SendCondition<UserContext> orCondition = LogicalConditions.not(refusingCondition); UserContext user = createUserContextObject(); boolean isApplicable = orCondition.isApplicable(user); assertTrue(isApplicable); }