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 AllPredicate implements Predicate, PredicateDecorator, Serializable { 32 33 34 static final long serialVersionUID = -3094696765038308799L; 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 AllPredicate(predicates); 52 } 53 54 63 public static Predicate getInstance(Collection predicates) { 64 Predicate[] preds = FunctorUtils.validate(predicates); 65 return new AllPredicate(preds); 66 } 67 68 74 public AllPredicate(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) == false) { 88 return false; 89 } 90 } 91 return true; 92 } 93 94 100 public Predicate[] getPredicates() { 101 return iPredicates; 102 } 103 104 } 105 | Popular Tags |