1 16 package org.apache.commons.collections.functors; 17 18 import java.io.Serializable ; 19 20 import org.apache.commons.collections.Predicate; 21 22 31 public final class InstanceofPredicate implements Predicate, Serializable { 32 33 34 static final long serialVersionUID = -6682656911025165584L; 35 36 37 private final Class iType; 38 39 46 public static Predicate getInstance(Class type) { 47 if (type == null) { 48 throw new IllegalArgumentException ("The type to check instanceof must not be null"); 49 } 50 return new InstanceofPredicate(type); 51 } 52 53 59 public InstanceofPredicate(Class type) { 60 super(); 61 iType = type; 62 } 63 64 70 public boolean evaluate(Object object) { 71 return (iType.isInstance(object)); 72 } 73 74 80 public Class getType() { 81 return iType; 82 } 83 84 } 85 | Popular Tags |