|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections4.PredicateUtils
public class PredicateUtils
PredicateUtils provides reference implementations and utilities
for the Predicate functor interface. The supplied predicates are:
| Method Summary | ||
|---|---|---|
static
|
allPredicate(Collection<? extends Predicate<T>> predicates)
Create a new Predicate that returns true only if all of the specified predicates are true. |
|
static
|
allPredicate(Predicate<? super T>... predicates)
Create a new Predicate that returns true only if all of the specified predicates are true. |
|
static
|
andPredicate(Predicate<? super T> predicate1,
Predicate<? super T> predicate2)
Create a new Predicate that returns true only if both of the specified predicates are true. |
|
static
|
anyPredicate(Collection<? extends Predicate<T>> predicates)
Create a new Predicate that returns true if any of the specified predicates are true. |
|
static
|
anyPredicate(Predicate<? super T>... predicates)
Create a new Predicate that returns true if any of the specified predicates are true. |
|
static
|
asPredicate(Transformer<? super T,Boolean> transformer)
Create a new Predicate that wraps a Transformer. |
|
static
|
eitherPredicate(Predicate<? super T> predicate1,
Predicate<? super T> predicate2)
Create a new Predicate that returns true if one, but not both, of the specified predicates are true. |
|
static
|
equalPredicate(T value)
Creates a Predicate that checks if the input object is equal to the specified object using equals(). |
|
static
|
exceptionPredicate()
Gets a Predicate that always throws an exception. |
|
static
|
falsePredicate()
Gets a Predicate that always returns false. |
|
static
|
identityPredicate(T value)
Creates a Predicate that checks if the input object is equal to the specified object by identity. |
|
static Predicate<Object> |
instanceofPredicate(Class<?> type)
Creates a Predicate that checks if the object passed in is of a particular type, using instanceof. |
|
static
|
invokerPredicate(String methodName)
Creates a Predicate that invokes a method on the input object. |
|
static
|
invokerPredicate(String methodName,
Class<?>[] paramTypes,
Object[] args)
Creates a Predicate that invokes a method on the input object. |
|
static
|
neitherPredicate(Predicate<? super T> predicate1,
Predicate<? super T> predicate2)
Create a new Predicate that returns true if neither of the specified predicates are true. |
|
static
|
nonePredicate(Collection<? extends Predicate<T>> predicates)
Create a new Predicate that returns true if none of the specified predicates are true. |
|
static
|
nonePredicate(Predicate<? super T>... predicates)
Create a new Predicate that returns true if none of the specified predicates are true. |
|
static
|
notNullPredicate()
Gets a Predicate that checks if the input object passed in is not null. |
|
static
|
notPredicate(Predicate<? super T> predicate)
Create a new Predicate that returns true if the specified predicate returns false and vice versa. |
|
static
|
nullIsExceptionPredicate(Predicate<? super T> predicate)
Gets a Predicate that throws an exception if the input object is null, otherwise it calls the specified Predicate. |
|
static
|
nullIsFalsePredicate(Predicate<? super T> predicate)
Gets a Predicate that returns false if the input object is null, otherwise it calls the specified Predicate. |
|
static
|
nullIsTruePredicate(Predicate<? super T> predicate)
Gets a Predicate that returns true if the input object is null, otherwise it calls the specified Predicate. |
|
static
|
nullPredicate()
Gets a Predicate that checks if the input object passed in is null. |
|
static
|
onePredicate(Collection<Predicate<T>> predicates)
Create a new Predicate that returns true if only one of the specified predicates are true. |
|
static
|
onePredicate(Predicate<? super T>... predicates)
Create a new Predicate that returns true if only one of the specified predicates are true. |
|
static
|
orPredicate(Predicate<? super T> predicate1,
Predicate<? super T> predicate2)
Create a new Predicate that returns true if either of the specified predicates are true. |
|
static
|
transformedPredicate(Transformer<? super T,? extends T> transformer,
Predicate<? super T> predicate)
Creates a predicate that transforms the input object before passing it to the predicate. |
|
static
|
truePredicate()
Gets a Predicate that always returns true. |
|
static
|
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 |
| Method Detail |
|---|
public static <T> Predicate<T> exceptionPredicate()
T - the type that the predicate queries
ExceptionPredicatepublic static <T> Predicate<T> truePredicate()
T - the type that the predicate queries
TruePredicatepublic static <T> Predicate<T> falsePredicate()
T - the type that the predicate queries
FalsePredicatepublic static <T> Predicate<T> nullPredicate()
T - the type that the predicate queries
NullPredicatepublic static <T> Predicate<T> notNullPredicate()
T - the type that the predicate queries
NotNullPredicatepublic static <T> Predicate<T> equalPredicate(T value)
T - the type that the predicate queriesvalue - the value to compare against
EqualPredicatepublic static <T> Predicate<T> identityPredicate(T value)
T - the type that the predicate queriesvalue - the value to compare against
IdentityPredicatepublic static Predicate<Object> instanceofPredicate(Class<?> type)
null input
object will return false.
type - the type to check for, may not be null
IllegalArgumentException - if the class is nullInstanceofPredicatepublic static <T> Predicate<T> uniquePredicate()
null input object
is accepted and will return true the first time, and false subsequently
as well.
T - the type that the predicate queries
UniquePredicatepublic static <T> Predicate<T> invokerPredicate(String methodName)
For example, PredicateUtils.invokerPredicate("isEmpty");
will call the isEmpty method on the input object to
determine the predicate result.
T - the type that the predicate queriesmethodName - the method name to call on the input object, may not be null
IllegalArgumentException - if the methodName is null.InvokerTransformer,
TransformerPredicate
public static <T> Predicate<T> 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.
T - the type that the predicate queriesmethodName - the method name to call on the input object, may not be nullparamTypes - the parameter typesargs - the arguments
IllegalArgumentException - if the method name is null
IllegalArgumentException - if the paramTypes and args don't matchInvokerTransformer,
TransformerPredicate
public static <T> Predicate<T> andPredicate(Predicate<? super T> predicate1,
Predicate<? super T> predicate2)
T - the type that the predicate queriespredicate1 - the first predicate, may not be nullpredicate2 - the second predicate, may not be null
and predicate
IllegalArgumentException - if either predicate is nullAndPredicatepublic static <T> Predicate<T> allPredicate(Predicate<? super T>... predicates)
T - the type that the predicate queriespredicates - an array of predicates to check, may not be null
all predicate
IllegalArgumentException - if the predicates array is null
IllegalArgumentException - if any predicate in the array is nullAllPredicatepublic static <T> Predicate<T> allPredicate(Collection<? extends Predicate<T>> predicates)
T - the type that the predicate queriespredicates - a collection of predicates to check, may not be null
all predicate
IllegalArgumentException - if the predicates collection is null
IllegalArgumentException - if any predicate in the collection is nullAllPredicate
public static <T> Predicate<T> orPredicate(Predicate<? super T> predicate1,
Predicate<? super T> predicate2)
T - the type that the predicate queriespredicate1 - the first predicate, may not be nullpredicate2 - the second predicate, may not be null
or predicate
IllegalArgumentException - if either predicate is nullOrPredicatepublic static <T> Predicate<T> anyPredicate(Predicate<? super T>... predicates)
T - the type that the predicate queriespredicates - an array of predicates to check, may not be null
any predicate
IllegalArgumentException - if the predicates array is null
IllegalArgumentException - if any predicate in the array is nullAnyPredicatepublic static <T> Predicate<T> anyPredicate(Collection<? extends Predicate<T>> predicates)
T - the type that the predicate queriespredicates - a collection of predicates to check, may not be null
any predicate
IllegalArgumentException - if the predicates collection is null
IllegalArgumentException - if any predicate in the collection is nullAnyPredicate
public static <T> Predicate<T> eitherPredicate(Predicate<? super T> predicate1,
Predicate<? super T> predicate2)
T - the type that the predicate queriespredicate1 - the first predicate, may not be nullpredicate2 - the second predicate, may not be null
either predicate
IllegalArgumentException - if either predicate is nullOnePredicatepublic static <T> Predicate<T> onePredicate(Predicate<? super T>... predicates)
T - the type that the predicate queriespredicates - an array of predicates to check, may not be null
one predicate
IllegalArgumentException - if the predicates array is null
IllegalArgumentException - if any predicate in the array is nullOnePredicatepublic static <T> Predicate<T> onePredicate(Collection<Predicate<T>> predicates)
T - the type that the predicate queriespredicates - a collection of predicates to check, may not be null
one predicate
IllegalArgumentException - if the predicates collection is null
IllegalArgumentException - if any predicate in the collection is nullOnePredicate
public static <T> Predicate<T> neitherPredicate(Predicate<? super T> predicate1,
Predicate<? super T> predicate2)
T - the type that the predicate queriespredicate1 - the first predicate, may not be nullpredicate2 - the second predicate, may not be null
neither predicate
IllegalArgumentException - if either predicate is nullNonePredicatepublic static <T> Predicate<T> nonePredicate(Predicate<? super T>... predicates)
T - the type that the predicate queriespredicates - an array of predicates to check, may not be null
none predicate
IllegalArgumentException - if the predicates array is null
IllegalArgumentException - if any predicate in the array is nullNonePredicatepublic static <T> Predicate<T> nonePredicate(Collection<? extends Predicate<T>> predicates)
T - the type that the predicate queriespredicates - a collection of predicates to check, may not be null
none predicate
IllegalArgumentException - if the predicates collection is null
IllegalArgumentException - if any predicate in the collection is nullNonePredicatepublic static <T> Predicate<T> notPredicate(Predicate<? super T> predicate)
T - the type that the predicate queriespredicate - the predicate to not
not predicate
IllegalArgumentException - if the predicate is nullNotPredicatepublic static <T> Predicate<T> asPredicate(Transformer<? super T,Boolean> transformer)
T - the type that the predicate queriestransformer - the transformer to wrap, may not be null
IllegalArgumentException - if the transformer is nullTransformerPredicatepublic static <T> Predicate<T> nullIsExceptionPredicate(Predicate<? super T> predicate)
T - the type that the predicate queriespredicate - the predicate to wrap, may not be null
IllegalArgumentException - if the predicate is null.NullIsExceptionPredicatepublic static <T> Predicate<T> nullIsFalsePredicate(Predicate<? super T> predicate)
T - the type that the predicate queriespredicate - the predicate to wrap, may not be null
IllegalArgumentException - if the predicate is null.NullIsFalsePredicatepublic static <T> Predicate<T> nullIsTruePredicate(Predicate<? super T> predicate)
T - the type that the predicate queriespredicate - the predicate to wrap, may not be null
IllegalArgumentException - if the predicate is null.NullIsTruePredicate
public static <T> Predicate<T> transformedPredicate(Transformer<? super T,? extends T> transformer,
Predicate<? super T> predicate)
T - the type that the predicate queriestransformer - the transformer to call firstpredicate - the predicate to call with the result of the transform
IllegalArgumentException - if the transformer or the predicate is nullTransformedPredicate
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||