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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to