Package org.parboiled.common
Class Predicates
java.lang.Object
org.parboiled.common.Predicates
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Predicate
<T> Returns a predicate that always evaluates tofalse
.static <T> Predicate
<T> Returns a predicate that always evaluates totrue
.static <T> Predicate
<T> and
(Collection<? extends Predicate<? super T>> components) Returns a predicate that evaluates totrue
if each of its components evaluates totrue
.static <T> Predicate
<T> Returns a predicate that evaluates totrue
if each of its components evaluates totrue
.static <T> Predicate
<T> Returns a predicate that evaluates totrue
if both of its components evaluate totrue
.static <T> Predicate
<T> equalTo
(T target) Returns a predicate that evaluates totrue
if the object being testedequals()
the given target or both are null.static <T> Predicate
<T> in
(Collection<? extends T> target) Returns a predicate that evaluates totrue
if the object reference being tested is a member of the given collection.instanceOf
(Class<?> clazz) Returns a predicate that evaluates totrue
if the object being tested is an instance of the given class.static <T> Predicate
<T> isNull()
Returns a predicate that evaluates totrue
if the object reference being tested is null.static <T> Predicate
<T> Returns a predicate that evaluates totrue
if the given predicate evaluates tofalse
.static <T> Predicate
<T> notNull()
Returns a predicate that evaluates totrue
if the object reference being tested is not null.static <T> Predicate
<T> or
(Collection<? extends Predicate<? super T>> components) Returns a predicate that evaluates totrue
if any one of its components evaluates totrue
.static <T> Predicate
<T> Returns a predicate that evaluates totrue
if any one of its components evaluates totrue
.static <T> Predicate
<T> Returns a predicate that evaluates totrue
if either of its components evaluates totrue
.
-
Method Details
-
alwaysTrue
Returns a predicate that always evaluates totrue
.- Returns:
- a predicate
-
alwaysFalse
Returns a predicate that always evaluates tofalse
.- Returns:
- a predicate
-
isNull
Returns a predicate that evaluates totrue
if the object reference being tested is null.- Returns:
- a predicate
-
notNull
Returns a predicate that evaluates totrue
if the object reference being tested is not null.- Returns:
- a predicate
-
not
Returns a predicate that evaluates totrue
if the given predicate evaluates tofalse
.- Parameters:
predicate
- the inner predicate- Returns:
- a predicate
-
and
Returns a predicate that evaluates totrue
if each of its components evaluates totrue
. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a false predicate is found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this predicate. Ifcomponents
is empty, the returned predicate will always evaluate totrue
.- Parameters:
components
- the components- Returns:
- a predicate
-
and
Returns a predicate that evaluates totrue
if each of its components evaluates totrue
. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a false predicate is found. It defensively copies the array passed in, so future changes to it won't alter the behavior of this predicate. Ifcomponents
is empty, the returned predicate will always evaluate totrue
.- Parameters:
components
- the components- Returns:
- a predicate
-
and
Returns a predicate that evaluates totrue
if both of its components evaluate totrue
. The components are evaluated in order, and evaluation will be "short-circuited" as soon as a false predicate is found.- Parameters:
first
- the firstsecond
- the second- Returns:
- a predicate
-
or
Returns a predicate that evaluates totrue
if any one of its components evaluates totrue
. The components are evaluated in order, and evaluation will be "short-circuited" as soon as as soon as a true predicate is found. It defensively copies the iterable passed in, so future changes to it won't alter the behavior of this predicate. Ifcomponents
is empty, the returned predicate will always evaluate tofalse
.- Parameters:
components
- the components- Returns:
- a predicate
-
or
Returns a predicate that evaluates totrue
if any one of its components evaluates totrue
. The components are evaluated in order, and evaluation will be "short-circuited" as soon as as soon as a true predicate is found. It defensively copies the array passed in, so future changes to it won't alter the behavior of this predicate. Ifcomponents
is empty, the returned predicate will always evaluate tofalse
.- Parameters:
components
- the components- Returns:
- a predicate
-
or
Returns a predicate that evaluates totrue
if either of its components evaluates totrue
. The components are evaluated in order, and evaluation will be "short-circuited" as soon as as soon as a true predicate is found.- Parameters:
first
- the firstsecond
- the second- Returns:
- a predicate
-
equalTo
Returns a predicate that evaluates totrue
if the object being testedequals()
the given target or both are null.- Parameters:
target
- the target- Returns:
- a predicate
-
instanceOf
Returns a predicate that evaluates totrue
if the object being tested is an instance of the given class. If the object being tested isnull
this predicate evaluates tofalse
.- Parameters:
clazz
- the clazz- Returns:
- a predicate
-
in
Returns a predicate that evaluates totrue
if the object reference being tested is a member of the given collection. It does not defensively copy the collection passed in, so future changes to it will alter the behavior of the predicate. This method can technically accept any Collectioninvalid input: '<'?>, but using a typed collection helps prevent bugs. This approach doesn't block any potential users since it is always possible to usePredicates.<Object>in()
.- Parameters:
target
- the collection that may contain the function input- Returns:
- a predicate
-