java.lang.Object | |
↳ | org.apache.commons.collections.PredicateUtils |
PredicateUtils
provides reference implementations and utilities
for the Predicate functor interface. The supplied predicates are:
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
This class is not normally instantiated.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Create a new Predicate that returns true only if all of the specified
predicates are true.
| |||||||||||
Create a new Predicate that returns true only if all of the specified
predicates are true.
| |||||||||||
Create a new Predicate that returns true only if both of the specified
predicates are true.
| |||||||||||
Create a new Predicate that returns true if any of the specified
predicates are true.
| |||||||||||
Create a new Predicate that returns true if any of the specified
predicates are true.
| |||||||||||
Create a new Predicate that wraps a Transformer.
| |||||||||||
Create a new Predicate that returns true if one, but not both, of the
specified predicates are true.
| |||||||||||
Creates a Predicate that checks if the input object is equal to the
specified object using equals().
| |||||||||||
Gets a Predicate that always throws an exception.
| |||||||||||
Gets a Predicate that always returns false.
| |||||||||||
Creates a Predicate that checks if the input object is equal to the
specified object by identity.
| |||||||||||
Creates a Predicate that checks if the object passed in is of
a particular type, using instanceof.
| |||||||||||
Creates a Predicate that invokes a method on the input object.
| |||||||||||
Creates a Predicate that invokes a method on the input object.
| |||||||||||
Create a new Predicate that returns true if neither of the specified
predicates are true.
| |||||||||||
Create a new Predicate that returns true if none of the specified
predicates are true.
| |||||||||||
Create a new Predicate that returns true if none of the specified
predicates are true.
| |||||||||||
Gets a Predicate that checks if the input object passed in is not null.
| |||||||||||
Create a new Predicate that returns true if the specified predicate
returns false and vice versa.
| |||||||||||
Gets a Predicate that throws an exception if the input object is null,
otherwise it calls the specified Predicate.
| |||||||||||
Gets a Predicate that returns false if the input object is null, otherwise
it calls the specified Predicate.
| |||||||||||
Gets a Predicate that returns true if the input object is null, otherwise
it calls the specified Predicate.
| |||||||||||
Gets a Predicate that checks if the input object passed in is null.
| |||||||||||
Create a new Predicate that returns true if only one of the specified
predicates are true.
| |||||||||||
Create a new Predicate that returns true if only one of the specified
predicates are true.
| |||||||||||
Create a new Predicate that returns true if either of the specified
predicates are true.
| |||||||||||
Creates a predicate that transforms the input object before passing it
to the predicate.
| |||||||||||
Gets a Predicate that always returns true.
| |||||||||||
Creates a Predicate that returns true the first time an object is
encountered, and false if the same object is received
again.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
This class is not normally instantiated.
Create a new Predicate that returns true only if all of the specified predicates are true. The predicates are checked in iterator order. If the collection of predicates is empty, then this predicate returns true.
predicates | a collection of predicates to check, may not be null |
---|
all
predicateIllegalArgumentException | if the predicates collection is null |
---|---|
IllegalArgumentException | if any predicate in the collection is null |
Create a new Predicate that returns true only if all of the specified predicates are true. If the array of predicates is empty, then this predicate returns true.
predicates | an array of predicates to check, may not be null |
---|
all
predicateIllegalArgumentException | if the predicates array is null |
---|---|
IllegalArgumentException | if any predicate in the array is null |
Create a new Predicate that returns true only if both of the specified predicates are true.
predicate1 | the first predicate, may not be null |
---|---|
predicate2 | the second predicate, may not be null |
and
predicateIllegalArgumentException | if either predicate is null |
---|
Create a new Predicate that returns true if any of the specified predicates are true. If the array of predicates is empty, then this predicate returns false.
predicates | an array of predicates to check, may not be null |
---|
any
predicateIllegalArgumentException | if the predicates array is null |
---|---|
IllegalArgumentException | if any predicate in the array is null |
Create a new Predicate that returns true if any of the specified predicates are true. The predicates are checked in iterator order. If the collection of predicates is empty, then this predicate returns false.
predicates | a collection of predicates to check, may not be null |
---|
any
predicateIllegalArgumentException | if the predicates collection is null |
---|---|
IllegalArgumentException | if any predicate in the collection is null |
Create a new Predicate that wraps a Transformer. The Transformer must return either Boolean.TRUE or Boolean.FALSE otherwise a PredicateException will be thrown.
transformer | the transformer to wrap, may not be null |
---|
IllegalArgumentException | if the transformer is null |
---|
Create a new Predicate that returns true if one, but not both, of the specified predicates are true.
predicate1 | the first predicate, may not be null |
---|---|
predicate2 | the second predicate, may not be null |
either
predicateIllegalArgumentException | if either predicate is null |
---|
Creates a Predicate that checks if the input object is equal to the specified object using equals().
value | the value to compare against |
---|
Gets a Predicate that always throws an exception. This could be useful during testing as a placeholder.
Creates a Predicate that checks if the input object is equal to the specified object by identity.
value | the value to compare against |
---|
Creates a Predicate that checks if the object passed in is of
a particular type, using instanceof. A null
input
object will return false
.
type | the type to check for, may not be null |
---|
IllegalArgumentException | if the class is null |
---|
Creates a Predicate that invokes a method on the input object. The method must return either a boolean or a non-null Boolean, and have no parameters. If the input object is null, a PredicateException is thrown.
For example, PredicateUtils.invokerPredicate("isEmpty");
will call the isEmpty
method on the input object to
determine the predicate result.
methodName | the method name to call on the input object, may not be null |
---|
IllegalArgumentException | if the methodName is null. |
---|
Creates a Predicate that invokes a method on the input object. The method must return either a boolean or a non-null Boolean, and have no parameters. If the input object is null, a PredicateException is thrown.
For example, PredicateUtils.invokerPredicate("isEmpty");
will call the isEmpty
method on the input object to
determine the predicate result.
methodName | the method name to call on the input object, may not be null |
---|---|
paramTypes | the parameter types |
args | the arguments |
IllegalArgumentException | if the method name is null |
---|---|
IllegalArgumentException | if the paramTypes and args don't match |
Create a new Predicate that returns true if neither of the specified predicates are true.
predicate1 | the first predicate, may not be null |
---|---|
predicate2 | the second predicate, may not be null |
neither
predicateIllegalArgumentException | if either predicate is null |
---|
Create a new Predicate that returns true if none of the specified predicates are true. The predicates are checked in iterator order. If the collection of predicates is empty, then this predicate returns true.
predicates | a collection of predicates to check, may not be null |
---|
none
predicateIllegalArgumentException | if the predicates collection is null |
---|---|
IllegalArgumentException | if any predicate in the collection is null |
Create a new Predicate that returns true if none of the specified predicates are true. If the array of predicates is empty, then this predicate returns true.
predicates | an array of predicates to check, may not be null |
---|
none
predicateIllegalArgumentException | if the predicates array is null |
---|---|
IllegalArgumentException | if any predicate in the array is null |
Gets a Predicate that checks if the input object passed in is not null.
Create a new Predicate that returns true if the specified predicate returns false and vice versa.
predicate | the predicate to not |
---|
not
predicateIllegalArgumentException | if the predicate is null |
---|
Gets a Predicate that throws an exception if the input object is null, otherwise it calls the specified Predicate. This allows null handling behaviour to be added to Predicates that don't support nulls.
predicate | the predicate to wrap, may not be null |
---|
IllegalArgumentException | if the predicate is null. |
---|
Gets a Predicate that returns false if the input object is null, otherwise it calls the specified Predicate. This allows null handling behaviour to be added to Predicates that don't support nulls.
predicate | the predicate to wrap, may not be null |
---|
IllegalArgumentException | if the predicate is null. |
---|
Gets a Predicate that returns true if the input object is null, otherwise it calls the specified Predicate. This allows null handling behaviour to be added to Predicates that don't support nulls.
predicate | the predicate to wrap, may not be null |
---|
IllegalArgumentException | if the predicate is null. |
---|
Gets a Predicate that checks if the input object passed in is null.
Create a new Predicate that returns true if only one of the specified predicates are true. The predicates are checked in iterator order. If the collection of predicates is empty, then this predicate returns false.
predicates | a collection of predicates to check, may not be null |
---|
one
predicateIllegalArgumentException | if the predicates collection is null |
---|---|
IllegalArgumentException | if any predicate in the collection is null |
Create a new Predicate that returns true if only one of the specified predicates are true. If the array of predicates is empty, then this predicate returns false.
predicates | an array of predicates to check, may not be null |
---|
one
predicateIllegalArgumentException | if the predicates array is null |
---|---|
IllegalArgumentException | if any predicate in the array is null |
Create a new Predicate that returns true if either of the specified predicates are true.
predicate1 | the first predicate, may not be null |
---|---|
predicate2 | the second predicate, may not be null |
or
predicateIllegalArgumentException | if either predicate is null |
---|
Creates a predicate that transforms the input object before passing it to the predicate.
transformer | the transformer to call first |
---|---|
predicate | the predicate to call with the result of the transform |
IllegalArgumentException | if the transformer or the predicate is null |
---|
Creates a Predicate that returns true the first time an object is
encountered, and false if the same object is received
again. The comparison is by equals(). A null
input object
is accepted and will return true the first time, and false subsequently
as well.