|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.collections15.PredicateUtils
public class 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
|
allPredicate(Collection<Predicate<? super 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<Predicate<? super 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<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 Predicate |
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 |
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
|
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<Predicate<? super 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<T> predicate)
Create a new Predicate that returns true if the specified predicate returns false and vice versa. |
|
static
|
nullIsExceptionPredicate(Predicate<T> predicate)
Gets a Predicate that throws an exception if the input object is null, otherwise it calls the specified Predicate. |
|
static
|
nullIsFalsePredicate(Predicate<T> predicate)
Gets a Predicate that returns false if the input object is null, otherwise it calls the specified Predicate. |
|
static
|
nullIsTruePredicate(Predicate<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<? super 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<I,? extends O> transformer,
Predicate<? super O> 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 |
Constructor Detail |
---|
public PredicateUtils()
Method Detail |
---|
public static Predicate exceptionPredicate()
ExceptionPredicate
public static <T> Predicate<T> truePredicate()
TruePredicate
public static <T> Predicate<T> falsePredicate()
FalsePredicate
public static <T> Predicate<T> nullPredicate()
NullPredicate
public static <T> Predicate<T> notNullPredicate()
NotNullPredicate
public static <T> Predicate<T> equalPredicate(T value)
value
- the value to compare against
EqualPredicate
public static <T> Predicate<T> identityPredicate(T value)
value
- the value to compare against
IdentityPredicate
public static Predicate instanceofPredicate(Class type)
null
input
object will return false
.
type
- the type to check for, may not be null
IllegalArgumentException
- if the class is nullInstanceofPredicate
public static <T> Predicate<T> uniquePredicate()
null
input object
is accepted and will return true the first time, and false subsequently
as well.
UniquePredicate
public static Predicate invokerPredicate(String methodName)
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.InvokerTransformer
,
TransformerPredicate
public 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.
methodName
- 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)
predicate1
- the first predicate, may not be nullpredicate2
- the second predicate, may not be null
and
predicate
IllegalArgumentException
- if either predicate is nullAndPredicate
public static <T> Predicate<T> allPredicate(Predicate<? super T>... predicates)
predicates
- an array of predicates to check, may not be null
all
predicate
IllegalArgumentException
- if the predicates array is null
IllegalArgumentException
- if the predicates array has less than 2 elements
IllegalArgumentException
- if any predicate in the array is nullAllPredicate
public static <T> Predicate<T> allPredicate(Collection<Predicate<? super T>> predicates)
predicates
- a collection of predicates to check, may not be null
all
predicate
IllegalArgumentException
- if the predicates collection is null
IllegalArgumentException
- if the predicates collection has less than 2 elements
IllegalArgumentException
- if any predicate in the collection is nullAllPredicate
public static <T> Predicate<T> orPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
predicate1
- the first predicate, may not be nullpredicate2
- the second predicate, may not be null
or
predicate
IllegalArgumentException
- if either predicate is nullOrPredicate
public static <T> Predicate<T> anyPredicate(Predicate<? super T>... predicates)
predicates
- an array of predicates to check, may not be null
any
predicate
IllegalArgumentException
- if the predicates array is null
IllegalArgumentException
- if the predicates array has less than 2 elements
IllegalArgumentException
- if any predicate in the array is nullAnyPredicate
public static <T> Predicate<T> anyPredicate(Collection<Predicate<? super T>> predicates)
predicates
- a collection of predicates to check, may not be null
any
predicate
IllegalArgumentException
- if the predicates collection is null
IllegalArgumentException
- if the predicates collection has less than 2 elements
IllegalArgumentException
- if any predicate in the collection is nullAnyPredicate
public static <T> Predicate<T> eitherPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
predicate1
- the first predicate, may not be nullpredicate2
- the second predicate, may not be null
either
predicate
IllegalArgumentException
- if either predicate is nullOnePredicate
public static <T> Predicate<T> onePredicate(Predicate<? super T>... predicates)
predicates
- an array of predicates to check, may not be null
one
predicate
IllegalArgumentException
- if the predicates array is null
IllegalArgumentException
- if the predicates array has less than 2 elements
IllegalArgumentException
- if any predicate in the array is nullOnePredicate
public static <T> Predicate<T> onePredicate(Collection<Predicate<? super T>> predicates)
predicates
- a collection of predicates to check, may not be null
one
predicate
IllegalArgumentException
- if the predicates collection is null
IllegalArgumentException
- if the predicates collection has less than 2 elements
IllegalArgumentException
- if any predicate in the collection is nullOnePredicate
public static <T> Predicate<T> neitherPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
predicate1
- the first predicate, may not be nullpredicate2
- the second predicate, may not be null
neither
predicate
IllegalArgumentException
- if either predicate is nullNonePredicate
public static <T> Predicate<T> nonePredicate(Predicate<? super T>... predicates)
predicates
- an array of predicates to check, may not be null
none
predicate
IllegalArgumentException
- if the predicates array is null
IllegalArgumentException
- if the predicates array has less than 2 elements
IllegalArgumentException
- if any predicate in the array is nullNonePredicate
public static <T> Predicate<T> nonePredicate(Collection<Predicate<? super T>> predicates)
predicates
- a collection of predicates to check, may not be null
none
predicate
IllegalArgumentException
- if the predicates collection is null
IllegalArgumentException
- if the predicates collection has less than 2 elements
IllegalArgumentException
- if any predicate in the collection is nullNonePredicate
public static <T> Predicate<T> notPredicate(Predicate<T> predicate)
predicate
- the predicate to not
not
predicate
IllegalArgumentException
- if the predicate is nullNotPredicate
public static <T> Predicate<T> asPredicate(Transformer<T,Boolean> transformer)
transformer
- the transformer to wrap, may not be null
IllegalArgumentException
- if the transformer is nullTransformerPredicate
public static <T> Predicate<T> nullIsExceptionPredicate(Predicate<T> predicate)
predicate
- the predicate to wrap, may not be null
IllegalArgumentException
- if the predicate is null.NullIsExceptionPredicate
public static <T> Predicate<T> nullIsFalsePredicate(Predicate<T> predicate)
predicate
- the predicate to wrap, may not be null
IllegalArgumentException
- if the predicate is null.NullIsFalsePredicate
public static <T> Predicate<T> nullIsTruePredicate(Predicate<T> predicate)
predicate
- the predicate to wrap, may not be null
IllegalArgumentException
- if the predicate is null.NullIsTruePredicate
public static <I,O> Predicate<I> transformedPredicate(Transformer<I,? extends O> transformer, Predicate<? super O> predicate)
transformer
- 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 |