Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/Predicates.java
r10040 r10286 80 80 * @param <T> The predicate type. 81 81 * @param clazz The class the elements must have. 82 * @return A predicate. 82 * @return The new predicate. 83 * @throws IllegalArgumentException if clazz is null 83 84 */ 84 85 public static <T> Predicate<T> isOfClass(final Class<? extends T> clazz) { 86 CheckParameterUtil.ensureParameterNotNull(clazz, "clazz"); 85 87 return new Predicate<T>() { 86 88 @Override 87 89 public boolean evaluate(T obj) { 88 90 return obj != null && obj.getClass() == clazz; 91 } 92 }; 93 } 94 95 /** 96 * Creates a new predicate that checks if the object is of a given class. 97 * @param <T> The predicate type. 98 * @param clazz The class objects need to be of. 99 * @return The new predicate. 100 * @throws IllegalArgumentException if clazz is null 101 * @since 10286 102 */ 103 public static <T> Predicate<T> isInstanceOf(final Class<? extends T> clazz) { 104 CheckParameterUtil.ensureParameterNotNull(clazz, "clazz"); 105 return new Predicate<T>() { 106 @Override 107 public boolean evaluate(T o) { 108 return clazz.isInstance(o); 89 109 } 90 110 }; … … 190 210 }; 191 211 } 212 192 213 }
Note:
See TracChangeset
for help on using the changeset viewer.