Example usage for org.apache.commons.collections PredicateUtils onePredicate

List of usage examples for org.apache.commons.collections PredicateUtils onePredicate

Introduction

In this page you can find the example usage for org.apache.commons.collections PredicateUtils onePredicate.

Prototype

public static Predicate onePredicate(Collection predicates) 

Source Link

Document

Create a new Predicate that returns true if only one of the specified predicates are true.

Usage

From source file:adalid.commons.util.ColUtils.java

public static <T> Collection<T> oneFilter(Collection<T> collection, Predicate... predicates) {
    if (collection == null || collection.isEmpty() || predicates == null) {
        return collection;
    } else {/*from  ww  w.j  a  va2s.c o m*/
        //          Collection<T> list = new ArrayList<T>();
        //          list.addAll(collection);
        Collection<T> list = new ArrayList<>(collection);
        Predicate predicate = PredicateUtils.onePredicate(predicates);
        CollectionUtils.filter(list, predicate);
        return list;
    }
}