Top Description Methods
java.util.function

public Interface Predicate<T>

Known Direct Implementers
jdk.internal.logger.SimpleConsoleLogger.CallerFinder
Annotations
@FunctionalInterface
Type Parameters
<T>
the type of the input to the predicate
Imports
java.util.Objects

Represents a predicate (boolean-valued function) of one argument.

This is a functional interface whose functional method is test(Object).

Since
1.8

Method Summary

Modifier and TypeMethod and Description
public default Predicate<T>

Returns:

a composed predicate that represents the short-circuiting logical AND of this predicate and the other predicate
and
(Predicate<? super T>
a predicate that will be logically-ANDed with this predicate
other
)

Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another.

public static <
the type of arguments to the predicate
T
>
Predicate<T>

Returns:

a predicate that tests if two arguments are equal according to Objects#equals(Object, Object)
isEqual
(Object
the object reference with which to compare for equality, which may be null
targetRef
)

Returns a predicate that tests if two arguments are equal according to Objects#equals(Object, Object).

public default Predicate<T>

Returns:

a predicate that represents the logical negation of this predicate
negate
()

Returns a predicate that represents the logical negation of this predicate.

public static <
the type of arguments to the specified predicate
T
>
Predicate<T>

Returns:

a predicate that negates the results of the supplied predicate
not
(Predicate<? super T>
predicate to negate
target
)

Returns a predicate that is the negation of the supplied predicate.

public default Predicate<T>

Returns:

a composed predicate that represents the short-circuiting logical OR of this predicate and the other predicate
or
(Predicate<? super T>
a predicate that will be logically-ORed with this predicate
other
)

Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another.

public boolean

Returns:

true if the input argument matches the predicate, otherwise false
test
(T
the input argument
t
)

Evaluates this predicate on the given argument.

Method Detail

andback to summary
public default Predicate<T> and(Predicate<? super T> other)

Returns a composed predicate that represents a short-circuiting logical AND of this predicate and another. When evaluating the composed predicate, if this predicate is false, then the other predicate is not evaluated.

Any exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the other predicate will not be evaluated.

Parameters
other:Predicate<? super T>

a predicate that will be logically-ANDed with this predicate

Returns:Predicate<T>

a composed predicate that represents the short-circuiting logical AND of this predicate and the other predicate

Exceptions
NullPointerException:
if other is null
isEqualback to summary
public static <T> Predicate<T> isEqual(Object targetRef)

Returns a predicate that tests if two arguments are equal according to Objects#equals(Object, Object).

Parameters
<T>
the type of arguments to the predicate
targetRef:Object

the object reference with which to compare for equality, which may be null

Returns:Predicate<T>

a predicate that tests if two arguments are equal according to Objects#equals(Object, Object)

negateback to summary
public default Predicate<T> negate()

Returns a predicate that represents the logical negation of this predicate.

Returns:Predicate<T>

a predicate that represents the logical negation of this predicate

notback to summary
public static <T> Predicate<T> not(Predicate<? super T> target)

Returns a predicate that is the negation of the supplied predicate. This is accomplished by returning result of the calling target.negate().

Parameters
<T>
the type of arguments to the specified predicate
target:Predicate<? super T>

predicate to negate

Returns:Predicate<T>

a predicate that negates the results of the supplied predicate

Annotations
@SuppressWarnings:unchecked
Exceptions
NullPointerException:
if target is null
Since
11
orback to summary
public default Predicate<T> or(Predicate<? super T> other)

Returns a composed predicate that represents a short-circuiting logical OR of this predicate and another. When evaluating the composed predicate, if this predicate is true, then the other predicate is not evaluated.

Any exceptions thrown during evaluation of either predicate are relayed to the caller; if evaluation of this predicate throws an exception, the other predicate will not be evaluated.

Parameters
other:Predicate<? super T>

a predicate that will be logically-ORed with this predicate

Returns:Predicate<T>

a composed predicate that represents the short-circuiting logical OR of this predicate and the other predicate

Exceptions
NullPointerException:
if other is null
testback to summary
public boolean test(T t)

Evaluates this predicate on the given argument.

Parameters
t:T

the input argument

Returns:boolean

true if the input argument matches the predicate, otherwise false