te the closure BeanPropertyValueEqualsPredicate predicate = new BeanPropertyValueEqualsPredicate( "activeEmployee", Boolean.FALSE ); // filter the Collection CollectionUtils.filter( peopleCollection, predicate );
This would take a Collection
of person objects and filter out any people whose activeEmployee
property is false
. Assuming...
- The top level object in the
peeopleCollection
is an object which represents a person. - The person object has a
getActiveEmployee()
method which returns the boolean value for the object's activeEmployee
property.
Another typical usage might look like: // create the closure BeanPropertyValueEqualsPredicate predicate = new BeanPropertyValueEqualsPredicate( "personId", "456-12-1234" ); // search the Collection CollectionUtils.find( peopleCollection, predicate );
This would search a Collection
of person objects and return the first object whose personId
property value equals 456-12-1234
. Assuming...
- The top level object in the
peeopleCollection
is an object which represents a person. - The person object has a
getPersonId()
method which returns the value for the object's personId
property.
@author Norm Deane
@see org.apache.commons.beanutils.PropertyUtils
@see org.apache.commons.collections.Predicate