| java.lang.Object org.apache.commons.collections.PredicateUtils
PredicateUtils | public class PredicateUtils (Code) | | 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
- Transformed - transforms the input before calling the predicate
All the supplied predicates are Serializable.
since: Commons Collections 3.0 version: $Revision: 377508 $ $Date: 2006-02-13 22:12:33 +0000 (Mon, 13 Feb 2006) $ author: Stephen Colebourne author: Ola Berg |
Constructor Summary | |
public | PredicateUtils() This class is not normally instantiated. |
Method Summary | |
public static Predicate | allPredicate(Predicate[] predicates) Create a new Predicate that returns true only if all of the specified
predicates are true. | public static Predicate | allPredicate(Collection predicates) Create a new Predicate that returns true only if all of the specified
predicates are true. | public static Predicate | andPredicate(Predicate predicate1, Predicate predicate2) Create a new Predicate that returns true only if both of the specified
predicates are true. | public static Predicate | anyPredicate(Predicate[] predicates) Create a new Predicate that returns true if any of the specified
predicates are true. | public static Predicate | anyPredicate(Collection predicates) Create a new Predicate that returns true if any of the specified
predicates are true. | public static Predicate | asPredicate(Transformer transformer) Create a new Predicate that wraps a Transformer. | public 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. | public static Predicate | equalPredicate(Object value) Creates a Predicate that checks if the input object is equal to the
specified object using equals(). | public static Predicate | exceptionPredicate() Gets a Predicate that always throws an exception. | public static Predicate | falsePredicate() Gets a Predicate that always returns false. | public static Predicate | identityPredicate(Object value) Creates a Predicate that checks if the input object is equal to the
specified object by identity. | public static Predicate | instanceofPredicate(Class type) Creates a Predicate that checks if the object passed in is of
a particular type, using instanceof. | public static Predicate | invokerPredicate(String methodName) 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. | public static Predicate | invokerPredicate(String methodName, Class[] paramTypes, Object[] args) 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. | public static Predicate | neitherPredicate(Predicate predicate1, Predicate predicate2) Create a new Predicate that returns true if neither of the specified
predicates are true. | public static Predicate | nonePredicate(Predicate[] predicates) Create a new Predicate that returns true if none of the specified
predicates are true. | public static Predicate | nonePredicate(Collection predicates) Create a new Predicate that returns true if none of the specified
predicates are true. | public static Predicate | notNullPredicate() Gets a Predicate that checks if the input object passed in is not null. | public static Predicate | notPredicate(Predicate predicate) Create a new Predicate that returns true if the specified predicate
returns false and vice versa. | public static Predicate | nullIsExceptionPredicate(Predicate predicate) Gets a Predicate that throws an exception if the input object is null,
otherwise it calls the specified Predicate. | public static Predicate | nullIsFalsePredicate(Predicate predicate) Gets a Predicate that returns false if the input object is null, otherwise
it calls the specified Predicate. | public static Predicate | nullIsTruePredicate(Predicate predicate) Gets a Predicate that returns true if the input object is null, otherwise
it calls the specified Predicate. | public static Predicate | nullPredicate() Gets a Predicate that checks if the input object passed in is null. | public static Predicate | onePredicate(Predicate[] predicates) Create a new Predicate that returns true if only one of the specified
predicates are true. | public static Predicate | onePredicate(Collection predicates) Create a new Predicate that returns true if only one of the specified
predicates are true. | public static Predicate | orPredicate(Predicate predicate1, Predicate predicate2) Create a new Predicate that returns true if either of the specified
predicates are true. | public static Predicate | transformedPredicate(Transformer transformer, Predicate predicate) Creates a predicate that transforms the input object before passing it
to the predicate. | public static Predicate | truePredicate() Gets a Predicate that always returns true. | public 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. |
PredicateUtils | public PredicateUtils()(Code) | | This class is not normally instantiated.
|
uniquePredicate | public static Predicate uniquePredicate()(Code) | | 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.
See Also: org.apache.commons.collections.functors.UniquePredicate the predicate |
|
|