You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Tim O'Brien <to...@discursive.com> on 2004/03/08 18:14:11 UTC
[beanutils] A BeanPredicate which wraps another Predicate
BeanUtils has a BeanPropertyValueEqualsPredicate, this Predicate uses
PropertyUtils to get a bean property and then checks to see if the bean
property equals a certain value.
This is great if your application needs to test a bean property for
equality, but it limits what can be done with the various Predicates now
available in collections 3.0.
I've added a BeanPredicate which allows you to decorate a Predicate to
act upon a bean property. This class is in the spirit of BeanComparator.
BeanPropertyValueEqualsPredicate predicate =
new BeanPropertyValueEqualsPredicate( "activeEmployee",
Boolean.FALSE );
Now becomes,
BeanPredicate predicate =
new BeanPredicate( "activeEmployee",
new EqualPredicate( Boolean.FALSE ) );
And it also allow for other predicates. To check for a null bean property:
BeanPredicate predicate =
new BeanPredicate( "name", NullPredicate.INSTANCE );
Or to test the type of a bean property:
BeanPredicate predicate =
new BeanPredicate( "name", new InstanceofPredicate(String.class) );
... and so on and so forth ...
Tim
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org