java.lang.Object | +--org.apache.commons.collections.PredicateUtils
This class is not normally instantiated. |
static Predicate | allPredicate(Predicate[] predicates) Create a new Predicate that returns true only if all of the specified predicates are true. |
static Predicate | allPredicate(Collection 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(Predicate[] predicates) Create a new Predicate that returns true if any 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 | 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 | Gets a Predicate that always throws an exception. |
static Predicate | 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(Predicate[] predicates) Create a new Predicate that returns true if none 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 | 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 | Gets a Predicate that checks if the input object passed in is null. |
static Predicate | onePredicate(Predicate[] predicates) Create a new Predicate that returns true if only one of the specified predicates are true. |
static Predicate | onePredicate(Collection 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 | Gets a Predicate that always returns true. |
static Predicate | Creates a Predicate that returns true the first time an object is encountered, and false if the same object is received again. |
public PredicateUtils()
public static Predicate allPredicate(Collection predicates)
- if the predicates collection is null
- if the predicates collection has less than 2 elements
- if any predicate in the collection is nullpublic static Predicate allPredicate(Predicate[] predicates)
- if the predicates array is null
- if the predicates array has less than 2 elements
- if any predicate in the array is nullpublic static Predicate andPredicate(Predicate predicate1, Predicate predicate2)
- if either predicate is nullpublic static Predicate anyPredicate(Collection predicates)
- if the predicates collection is null
- if the predicates collection has less than 2 elements
- if any predicate in the collection is nullpublic static Predicate anyPredicate(Predicate[] predicates)
- if the predicates array is null
- if the predicates array has less than 2 elements
- if any predicate in the array is nullpublic static Predicate asPredicate(Transformer transformer)
- if the transformer is nullpublic static Predicate eitherPredicate(Predicate predicate1, Predicate predicate2)
- if either predicate is nullpublic static Predicate equalPredicate(Object value)
public static Predicate exceptionPredicate()
public static Predicate falsePredicate()
public static Predicate identityPredicate(Object value)
public static Predicate instanceofPredicate(Class type)
null
input
object will return false
.
- if the class is nullpublic static Predicate invokerPredicate(String methodName, Class[] paramTypes, Object[] args)
PredicateUtils.invokerPredicate("isEmpty");
will call the isEmpty
method on the input object to
determine the predicate result.
- if the method name is null
- if the paramTypes and args don't matchpublic static Predicate invokerPredicate(String methodName)
PredicateUtils.invokerPredicate("isEmpty");
will call the isEmpty
method on the input object to
determine the predicate result.
- if the methodName is null.public static Predicate neitherPredicate(Predicate predicate1, Predicate predicate2)
- if either predicate is nullpublic static Predicate nonePredicate(Collection predicates)
- if the predicates collection is null
- if the predicates collection has less than 2 elements
- if any predicate in the collection is nullpublic static Predicate nonePredicate(Predicate[] predicates)
- if the predicates array is null
- if the predicates array has less than 2 elements
- if any predicate in the array is nullpublic static Predicate notNullPredicate()
public static Predicate notPredicate(Predicate predicate)
- if the predicate is nullpublic static Predicate nullIsExceptionPredicate(Predicate predicate)
- if the predicate is null.public static Predicate nullIsFalsePredicate(Predicate predicate)
- if the predicate is null.public static Predicate nullIsTruePredicate(Predicate predicate)
- if the predicate is null.public static Predicate nullPredicate()
public static Predicate onePredicate(Collection predicates)
- if the predicates collection is null
- if the predicates collection has less than 2 elements
- if any predicate in the collection is nullpublic static Predicate onePredicate(Predicate[] predicates)
- if the predicates array is null
- if the predicates array has less than 2 elements
- if any predicate in the array is nullpublic static Predicate orPredicate(Predicate predicate1, Predicate predicate2)
- if either predicate is nullpublic static Predicate truePredicate()
public static Predicate uniquePredicate()
null
input object
is accepted and will return true the first time, and false subsequently
as well.
PredicateUtils
provides reference implementations and utilities for the Predicate functor interface. The supplied predicates are:- Invoker - returns the result of a method call on the input object
- InstanceOf - true if the object is an instanceof a class
- Equal - true if the object equals() a specified object
- Identity - true if the object == a specified object
- Null - true if the object is null
- NotNull - true if the object is not null
- Unique - true if the object has not already been evaluated
- And/All - true if all of the predicates are true
- Or/Any - true if any of the predicates is true
- Either/One - true if only one of the predicate is true
- Neither/None - true if none of the predicates are true
- Not - true if the predicate is false, and vice versa
- Transformer - wraps a Transformer as a Predicate
- True - always return true
- False - always return false
- Exception - always throws an exception
- NullIsException/NullIsFalse/NullIsTrue - check for null input
All the supplied predicates are Serializable.