Predicate: Difference between revisions
Jump to navigation
Jump to search
(Created page with "=External= * https://docs.oracle.com/javase/10/docs/api/java/util/function/Predicate.html =Internal= * Java 8 Lambda Expressions =...") |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 12: | Line 12: | ||
<syntaxhighlight lang='java'> | <syntaxhighlight lang='java'> | ||
@FunctionalInterface | |||
public interface Predicate<T> { | |||
boolean test(T t); | |||
... | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=Composition= | =Primitive Type Predicates= | ||
* <tt>[https://docs.oracle.com/javase/8/docs/api/java/util/function/IntPredicate.html IntPredicate]</tt> | |||
* <tt>[https://docs.oracle.com/javase/8/docs/api/java/util/function/LongPredicate.html LongPredicate]</tt> | |||
* <tt>[https://docs.oracle.com/javase/8/docs/api/java/util/function/DoublePredicate.html DoublePredicate]</tt> | |||
=Composition Methods= | |||
The precedence of methods <tt>and()</tt> and <tt>or()</tt> is managed from left to right using their positions in the chain. | |||
* [https://docs.oracle.com/javase/10/docs/api/java/util/function/Predicate.html#negate() negate()] | |||
* [https://docs.oracle.com/javase/10/docs/api/java/util/function/Predicate.html#and(java.util.function.Predicate) and(Predicate)] | |||
* [https://docs.oracle.com/javase/10/docs/api/java/util/function/Predicate.html#or(java.util.function.Predicate) or(Predicate)] |
Latest revision as of 19:46, 29 March 2018
External
Internal
Overview
A predicate is a function that evaluates an argument and returns a boolean.
@FunctionalInterface
public interface Predicate<T> {
boolean test(T t);
...
}
Primitive Type Predicates
Composition Methods
The precedence of methods and() and or() is managed from left to right using their positions in the chain.