读书人

Predicate接口引见

发布时间: 2012-11-13 10:00:50 作者: rapoo

Predicate接口介绍

1、Predicate是Commons Collections中定义的一个接口。具体

import java.util.Collection;import org.apache.commons.collections.Predicate;/** * @author zoopnin *  * 功能:判读集合中是否存在指定的对象  *  *  */public class ContainsPredicate implements Predicate {private final Collection<?> objs;public ContainsPredicate(Collection<?> objs) {super();this.objs = objs;}public boolean evaluate(Object object) {if (object instanceof Collection<?>) {return objs.containsAll((Collection<?>) object);} else {return objs.contains(object);}}}

?

?

?

读书人网 >编程

热点推荐