package ru.yandex.autotests.direct.utils.beans;

import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.collections.Predicate;

/**
 * Created with IntelliJ IDEA.
 * User: mariabye
 * Date: 21.05.13
 * Time: 21:52
 * To change this template use File | Settings | File Templates.
 */
public class BeanPropertyPredicate implements Predicate {
    private Object expected;
    private String propertyName;

    public BeanPropertyPredicate(String propertyName, Object expected) {
        super();
        this.propertyName = propertyName;
        this.expected = expected;
    }

    public boolean evaluate(Object object) {
        try {
            return expected.equals(PropertyUtils.getProperty(object, propertyName));
        } catch (Exception e) {
            return false;
        }
    }


}
