|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.collections.PredicateUtils
PredicateUtils
provides reference implementations and utilities
for the Predicate functor interface. The supplied predicates are:
Constructor Summary | |
PredicateUtils()
This class is not normally instantiated. |
Method Summary | |
static Predicate |
allPredicate(Collection predicates)
Create a new Predicate that returns true only if all of the specified predicates are true. |
static Predicate |
allPredicate(Predicate[] predicates)
Create a new Predicate that returns true only if all of the specified predicates are true. |
static Predicate |
andPredicate(Predicate predicate1,
Predicate predicate2)
Create a new Predicate that returns true only if both of the specified predicates are true. |
static Predicate |
anyPredicate(Collection predicates)
Create a new Predicate that returns true if any of the specified predicates are true. |
static Predicate |
anyPredicate(Predicate[] predicates)
Create a new Predicate that returns true if any of the specified predicates are true. |
static Predicate |
asPredicate(Transformer transformer)
Create a new Predicate that wraps a Transformer. |
static Predicate |
eitherPredicate(Predicate predicate1,
Predicate predicate2)
Create a new Predicate that returns true if one, but not both, of the specified predicates are true. |
static Predicate |
equalPredicate(Object value)
Creates a Predicate that checks if the input object is equal to the specified object using equals(). |
static Predicate |
exceptionPredicate()
Gets a Predicate that always throws an exception. |
static Predicate |
falsePredicate()
Gets a Predicate that always returns false. |
static Predicate |
identityPredicate(Object value)
Creates a Predicate that checks if the input object is equal to the specified object by identity. |
static Predicate |
instanceofPredicate(Class type)
Creates a Predicate that checks if the object passed in is of a particular type, using instanceof. |
static Predicate |
invokerPredicate(String methodName)
Creates a Predicate that invokes a method on the input object. |
static Predicate |
invokerPredicate(String methodName,
Class[] paramTypes,
Object[] args)
Creates a Predicate that invokes a method on the input object. |
static Predicate |
neitherPredicate(Predicate predicate1,
Predicate predicate2)
Create a new Predicate that returns true if neither of the specified predicates are true. |
static Predicate |
nonePredicate(Collection predicates)
Create a new Predicate that returns true if none of the specified predicates are true. |
static Predicate |
nonePredicate(Predicate[] predicates)
Create a new Predicate that returns true if none of the specified predicates are true. |
static Predicate |
notNullPredicate()
Gets a Predicate that checks if the input object passed in is not null. |
static Predicate |
notPredicate(Predicate predicate)
Create a new Predicate that returns true if the specified predicate returns false and vice versa. |
static Predicate |
nullIsExceptionPredicate(Predicate predicate)
Gets a Predicate that throws an exception if the input object is null, otherwise it calls the specified Predicate. |
static Predicate |
nullIsFalsePredicate(Predicate predicate)
Gets a Predicate that returns false if the input object is null, otherwise it calls the specified Predicate. |
static Predicate |
nullIsTruePredicate(Predicate predicate)
Gets a Predicate that returns true if the input object is null, otherwise it calls the specified Predicate. |
static Predicate |
nullPredicate()
Gets a Predicate that checks if the input object passed in is null. |
static Predicate |
onePredicate(Collection predicates)
Create a new Predicate that returns true if only one of the specified predicates are true. |
static Predicate |
onePredicate(Predicate[] predicates)
Create a new Predicate that returns true if only one of the specified predicates are true. |
static Predicate |
orPredicate(Predicate predicate1,
Predicate predicate2)
Create a new Predicate that returns true if either of the specified predicates are true. |
static Predicate |
truePredicate()
Gets a Predicate that always returns true. |
static Predicate |
uniquePredicate()
Creates a Predicate that returns true the first time an object is encountered, and false if the same object is received again. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public PredicateUtils()
Method Detail |
public static Predicate exceptionPredicate()
public static Predicate truePredicate()
public static Predicate falsePredicate()
public static Predicate nullPredicate()
public static Predicate notNullPredicate()
public static Predicate equalPredicate(Object value)
value
- the value to compare againstpublic static Predicate identityPredicate(Object value)
value
- the value to compare againstpublic static Predicate instanceofPredicate(Class type)
null
input
object will return false
.type
- the type to check for, may not be nullIllegalArgumentException
- if the class is nullpublic static Predicate uniquePredicate()
null
input object
is accepted and will return true the first time, and false subsequently
as well.public static Predicate invokerPredicate(String methodName)
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 nullIllegalArgumentException
- if the methodName is null.public static Predicate invokerPredicate(String methodName, Class[] paramTypes, Object[] args)
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 nullparamTypes
- the parameter typesargs
- the argumentsIllegalArgumentException
- if the method name is nullIllegalArgumentException
- if the paramTypes and args don't matchpublic static Predicate andPredicate(Predicate predicate1, Predicate predicate2)
predicate1
- the first predicate, may not be nullpredicate2
- the second predicate, may not be nulland
predicateIllegalArgumentException
- if either predicate is nullpublic static Predicate allPredicate(Predicate[] predicates)
predicates
- an array of predicates to check, may not be nullall
predicateIllegalArgumentException
- if the predicates array is nullIllegalArgumentException
- if the predicates array has less than 2 elementsIllegalArgumentException
- if any predicate in the array is nullpublic static Predicate allPredicate(Collection predicates)
predicates
- a collection of predicates to check, may not be nullall
predicateIllegalArgumentException
- if the predicates collection is nullIllegalArgumentException
- if the predicates collection has less than 2 elementsIllegalArgumentException
- if any predicate in the collection is nullpublic static Predicate orPredicate(Predicate predicate1, Predicate predicate2)
predicate1
- the first predicate, may not be nullpredicate2
- the second predicate, may not be nullor
predicateIllegalArgumentException
- if either predicate is nullpublic static Predicate anyPredicate(Predicate[] predicates)
predicates
- an array of predicates to check, may not be nullany
predicateIllegalArgumentException
- if the predicates array is nullIllegalArgumentException
- if the predicates array has less than 2 elementsIllegalArgumentException
- if any predicate in the array is nullpublic static Predicate anyPredicate(Collection predicates)
predicates
- a collection of predicates to check, may not be nullany
predicateIllegalArgumentException
- if the predicates collection is nullIllegalArgumentException
- if the predicates collection has less than 2 elementsIllegalArgumentException
- if any predicate in the collection is nullpublic static Predicate eitherPredicate(Predicate predicate1, Predicate predicate2)
predicate1
- the first predicate, may not be nullpredicate2
- the second predicate, may not be nulleither
predicateIllegalArgumentException
- if either predicate is nullpublic static Predicate onePredicate(Predicate[] predicates)
predicates
- an array of predicates to check, may not be nullone
predicateIllegalArgumentException
- if the predicates array is nullIllegalArgumentException
- if the predicates array has less than 2 elementsIllegalArgumentException
- if any predicate in the array is nullpublic static Predicate onePredicate(Collection predicates)
predicates
- a collection of predicates to check, may not be nullone
predicateIllegalArgumentException
- if the predicates collection is nullIllegalArgumentException
- if the predicates collection has less than 2 elementsIllegalArgumentException
- if any predicate in the collection is nullpublic static Predicate neitherPredicate(Predicate predicate1, Predicate predicate2)
predicate1
- the first predicate, may not be nullpredicate2
- the second predicate, may not be nullneither
predicateIllegalArgumentException
- if either predicate is nullpublic static Predicate nonePredicate(Predicate[] predicates)
predicates
- an array of predicates to check, may not be nullnone
predicateIllegalArgumentException
- if the predicates array is nullIllegalArgumentException
- if the predicates array has less than 2 elementsIllegalArgumentException
- if any predicate in the array is nullpublic static Predicate nonePredicate(Collection predicates)
predicates
- a collection of predicates to check, may not be nullnone
predicateIllegalArgumentException
- if the predicates collection is nullIllegalArgumentException
- if the predicates collection has less than 2 elementsIllegalArgumentException
- if any predicate in the collection is nullpublic static Predicate notPredicate(Predicate predicate)
predicate
- the predicate to notnot
predicateIllegalArgumentException
- if the predicate is nullpublic static Predicate asPredicate(Transformer transformer)
transformer
- the transformer to wrap, may not be nullIllegalArgumentException
- if the transformer is nullpublic static Predicate nullIsExceptionPredicate(Predicate predicate)
predicate
- the predicate to wrap, may not be nullIllegalArgumentException
- if the predicate is null.public static Predicate nullIsFalsePredicate(Predicate predicate)
predicate
- the predicate to wrap, may not be nullIllegalArgumentException
- if the predicate is null.public static Predicate nullIsTruePredicate(Predicate predicate)
predicate
- the predicate to wrap, may not be nullIllegalArgumentException
- if the predicate is null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |