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 NullIsTruePredicate implements Predicate, PredicateDecorator, Serializable { 31 32 33 static final long serialVersionUID = -7625133768987126273L; 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 NullIsTruePredicate(predicate); 50 } 51 52 58 public NullIsTruePredicate(Predicate predicate) { 59 super(); 60 iPredicate = predicate; 61 } 62 63 70 public boolean evaluate(Object object) { 71 if (object == null) { 72 return true; 73 } 74 return iPredicate.evaluate(object); 75 } 76 77 83 public Predicate[] getPredicates() { 84 return new Predicate[] {iPredicate}; 85 } 86 87 } 88 | Popular Tags |