1 16 package org.apache.commons.collections.functors; 17 18 import java.io.Serializable ; 19 20 import org.apache.commons.collections.Predicate; 21 22 30 public final class NotPredicate implements Predicate, PredicateDecorator, Serializable { 31 32 33 static final long serialVersionUID = -2654603322338049674L; 34 35 36 private final Predicate iPredicate; 37 38 45 public static Predicate getInstance(Predicate predicate) { 46 if (predicate == null) { 47 throw new IllegalArgumentException ("Predicate must not be null"); 48 } 49 return new NotPredicate(predicate); 50 } 51 52 58 public NotPredicate(Predicate predicate) { 59 super(); 60 iPredicate = predicate; 61 } 62 63 69 public boolean evaluate(Object object) { 70 return !(iPredicate.evaluate(object)); 71 } 72 73 79 public Predicate[] getPredicates() { 80 return new Predicate[] {iPredicate}; 81 } 82 83 } 84 | Popular Tags |