⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 daterangepredicate.java

📁 一个很好的开源项目管理系统源代码
💻 JAVA
字号:
package net.java.workeffort.infrastructure.utils;import java.util.List;import net.java.workeffort.infrastructure.Constants;import org.apache.commons.beanutils.PropertyUtils;import org.apache.commons.collections.Predicate;/** * A predicate which returns rows which meet the filter criteria. * <p> * Used in date range validation of multiple rows * @author Antony Joseph */public class DateRangePredicate implements Predicate {    private Object bean;    private List filterKeys;    public DateRangePredicate(Object bean, List filterKeys) {        if (filterKeys == null)            throw new IllegalArgumentException("filterKeys cannot be null");        if (bean == null)            throw new IllegalArgumentException("bean cannot be null");        this.bean = bean;        this.filterKeys = filterKeys;    }    public boolean evaluate(Object row) {        // if bean is a deleted row just return false;        if (getSimpleProperty(bean, Constants.PROCESS_TYPE) != null                && ((String) getSimpleProperty(bean, Constants.PROCESS_TYPE))                        .equals(Constants.PROCESS_TYPE_DELETE)) {            return false;        }        //Skip the same row.        if (row == bean)            return false;        // no need to validate range against a row being deleted.        if (getSimpleProperty(row, Constants.PROCESS_TYPE) != null                && ((String) getSimpleProperty(row, Constants.PROCESS_TYPE))                        .equals(Constants.PROCESS_TYPE_DELETE)) {            return false;        }        for (int i = 0; i < filterKeys.size(); i++) {            if (!getSimpleProperty(row, (String) filterKeys.get(i)).equals(                    getSimpleProperty(bean, (String) filterKeys.get(i)))) {                return false;            }        }        return true;    }    private Object getSimpleProperty(Object obj, String propertyName) {        try {            return PropertyUtils.getSimpleProperty(obj, propertyName);        }        catch (Exception e) {            throw new RuntimeException("Error while getting property:"                    + propertyName + " from object:" + obj, e);        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -