1 16 package org.apache.commons.collections.functors; 17 18 import java.io.Serializable ; 19 20 import org.apache.commons.collections.FunctorException; 21 import org.apache.commons.collections.Predicate; 22 23 31 public final class NullIsExceptionPredicate implements Predicate, PredicateDecorator, Serializable { 32 33 34 static final long serialVersionUID = 3243449850504576071L; 35 36 37 private final Predicate iPredicate; 38 39 46 public static Predicate getInstance(Predicate predicate) { 47 if (predicate == null) { 48 throw new IllegalArgumentException ("Predicate must not be null"); 49 } 50 return new NullIsExceptionPredicate(predicate); 51 } 52 53 59 public NullIsExceptionPredicate(Predicate predicate) { 60 super(); 61 iPredicate = predicate; 62 } 63 64 72 public boolean evaluate(Object object) { 73 if (object == null) { 74 throw new FunctorException("Input Object must not be null"); 75 } 76 return iPredicate.evaluate(object); 77 } 78 79 85 public Predicate[] getPredicates() { 86 return new Predicate[] {iPredicate}; 87 } 88 89 } 90 | Popular Tags |