A logical predicate, which can be combined with or and and operations, or negated.
Predicate<Integer> predicate;Boolean result;// Predicate initialization is skippedresult =predicate.test(12);
Logical Operations
The interface contains default methods for boolean operations:
Predicate<Integer> predicate1;Predicate<Integer> predicate2;Predicate<Integer> alwaysTrue;Predicate<Integer> alwaysFalse;Predicate<Integer> both;Predicate<Integer> one;// Predicate initialization is skipped// True if both are trueboth =predicate1.and(predicate2);// True if one is trueone =predicate1.or(predicate2);// ReversedalwaysFalse =alwaysTrue.negate();
Extensions
Just like with functions there is a BiPredicate and a few extensions for numeric primitives.