Package org.apache.commons.beanutils2
Class BeanPredicate<T>
java.lang.Object
org.apache.commons.beanutils2.BeanPredicate<T>
- Type Parameters:
T- the type of the input to the predicate
- All Implemented Interfaces:
Predicate<T>
Predicate implementation that applies the given Predicate to the result of calling the given property getter.
-
Constructor Summary
ConstructorsConstructorDescriptionBeanPredicate(String propertyName, Predicate<T> predicate) Constructs aBeanPredicatethat applies the givenPredicateto the named property value. -
Method Summary
Modifier and TypeMethodDescriptionGets thePredicateto be applied to the value of the named property duringtest(Object).Gets the name of the property whose value is to be predicated. in the evaluation.voidsetPredicate(Predicate<T> predicate) Sets thePredicateto be applied to the value of the named property duringtest(Object).voidsetPropertyName(String propertyName) Sets the name of the property whose value is to be predicated.booleanEvaluates the given object by applying thegetPredicate()to a property value named bygetPropertyName().
-
Constructor Details
-
BeanPredicate
Constructs aBeanPredicatethat applies the givenPredicateto the named property value.- Parameters:
propertyName- the name of the property whose value is to be predicated, not nullpredicate- thePredicateto be applied, not null
-
-
Method Details
-
getPredicate
Gets thePredicateto be applied to the value of the named property duringtest(Object).- Returns:
Predicate, not null
-
getPropertyName
Gets the name of the property whose value is to be predicated. in the evaluation.- Returns:
- the property name, not null
-
setPredicate
Sets thePredicateto be applied to the value of the named property duringtest(Object).- Parameters:
predicate-Predicate, not null
-
setPropertyName
Sets the name of the property whose value is to be predicated.- Parameters:
propertyName- the name of the property whose value is to be predicated, not null
-
test
Evaluates the given object by applying thegetPredicate()to a property value named bygetPropertyName().- Specified by:
testin interfacePredicate<T>- Parameters:
object- The object to test- Returns:
- the result of the predicate evaluation
- Throws:
IllegalArgumentException- when the property cannot be evaluated
-