FileDocCategorySizeDatePackage
PropertyPredicate.javaAPI DocExample1717Wed May 18 09:39:00 BST 2005com.discursive.jccook.collections.predicate

PropertyPredicate

public class PropertyPredicate extends Object implements org.apache.commons.collections.Predicate

Fields Summary
private String
property
private Object
matchValue
Constructors Summary
public PropertyPredicate(String property)


	   
		this.property = property;
	
public PropertyPredicate(String property, Object matchValue)

		this.property = property;
		this.matchValue = matchValue;
	
Methods Summary
public booleanevaluate(java.lang.Object object)

		boolean propertyFound = false;
		try {
			Object value = PropertyUtils.getProperty( object, property );
			if( value != null ) {
				if( matchValue != null ) {
					propertyFound = matchValue.equals( value );					
				} else {
					propertyFound = true;
				}
			}
		} catch(Exception e) {
			// If there was an exception, the predicate returns false
		}
		return propertyFound;