Example usage for org.apache.commons.collections.functors AnyPredicate AnyPredicate

List of usage examples for org.apache.commons.collections.functors AnyPredicate AnyPredicate

Introduction

In this page you can find the example usage for org.apache.commons.collections.functors AnyPredicate AnyPredicate.

Prototype

public AnyPredicate(Predicate[] predicates) 

Source Link

Document

Constructor that performs no validation.

Usage

From source file:com.newlandframework.avatarmq.broker.ProducerMessageHook.java

private void filterByTopic(String topic) {
    Predicate focusAllPredicate = new Predicate() {
        public boolean evaluate(Object object) {
            ConsumerClusters clusters = (ConsumerClusters) object;
            return clusters.findSubscriptionData(topic) != null;
        }//from   w  ww.jav a  2  s.  c o m
    };

    AnyPredicate any = new AnyPredicate(new Predicate[] { focusAllPredicate });

    Closure joinClosure = new Closure() {
        public void execute(Object input) {
            if (input instanceof ConsumerClusters) {
                ConsumerClusters clusters = (ConsumerClusters) input;
                clustersSet.add(clusters);
            }
        }
    };

    Closure ignoreClosure = new Closure() {
        public void execute(Object input) {
        }
    };

    Closure ifClosure = ClosureUtils.ifClosure(any, joinClosure, ignoreClosure);

    CollectionUtils.forAllDo(focusTopicGroup, ifClosure);
}

From source file:org.openfaces.component.filter.PredicateBuilder.java

/**
 * Used by the <code>build</code> method internally. This method shouldn't normally be invoked by application
 * developers./*w  w w .j av  a2s . c o m*/
 */
public Object process(OrFilterCriterion criterion) {
    List<FilterCriterion> criteria = criterion.getCriteria();
    Predicate[] predicates = new Predicate[criteria.size()];
    for (int i = 0; i < criteria.size(); i++) {
        FilterCriterion filterCriterion = criteria.get(i);
        predicates[i] = (Predicate) filterCriterion.process(this);
    }
    return new AnyPredicate(predicates);
}