1 16 package org.apache.commons.collections.functors; 17 18 import java.io.Serializable ; 19 import java.util.Collection ; 20 21 import org.apache.commons.collections.Predicate; 22 23 31 public final class AnyPredicate implements Predicate, PredicateDecorator, Serializable { 32 33 34 static final long serialVersionUID = 7429999530934647542L; 35 36 37 private final Predicate[] iPredicates; 38 39 48 public static Predicate getInstance(Predicate[] predicates) { 49 FunctorUtils.validateMin2(predicates); 50 predicates = FunctorUtils.copy(predicates); 51 return new AnyPredicate(predicates); 52 } 53 54 63 public static Predicate getInstance(Collection predicates) { 64 Predicate[] preds = FunctorUtils.validate(predicates); 65 return new AnyPredicate(preds); 66 } 67 68 74 public AnyPredicate(Predicate[] predicates) { 75 super(); 76 iPredicates = predicates; 77 } 78 79 85 public boolean evaluate(Object object) { 86 for (int i = 0; i < iPredicates.length; i++) { 87 if (iPredicates[i].evaluate(object)) { 88 return true; 89 } 90 } 91 return false; 92 } 93 94 100 public Predicate[] getPredicates() { 101 return iPredicates; 102 } 103 104 } 105 | Popular Tags |