/** * Factory to create the identity predicate. * * @param type the type to check for, may not be null * @return the predicate * @throws IllegalArgumentException if the class is null */ public static Predicate getInstance(Class type) { if (type == null) { throw new IllegalArgumentException("The type to check instanceof must not be null"); } return new InstanceofPredicate(type); }
/** * Creates a Predicate that checks if the object passed in is of * a particular type, using instanceof. A <code>null</code> input * object will return <code>false</code>. * * @see org.apache.commons.collections.functors.InstanceofPredicate * * @param type the type to check for, may not be null * @return the predicate * @throws IllegalArgumentException if the class is null */ public static Predicate instanceofPredicate(Class type) { return InstanceofPredicate.getInstance(type); }
private static boolean addExtension(GhprbExtension extension, List<Predicate> predicates, Set<Class<?>> extSet) { for (Predicate predicate : predicates) { if (predicate.evaluate(extension)) { Class<?> clazz = ((InstanceofPredicate) predicate).getType(); if (extSet.contains(clazz)) { return false; } else { extSet.add(clazz); return true; } } } return true; }
/** * Creates a Predicate that checks if the object passed in is of * a particular type, using instanceof. A <code>null</code> input * object will return <code>false</code>. * * @see org.apache.commons.collections.functors.InstanceofPredicate * * @param type the type to check for, may not be null * @return the predicate * @throws IllegalArgumentException if the class is null */ public static Predicate instanceofPredicate(Class type) { return InstanceofPredicate.getInstance(type); }
/** * Factory to create the identity predicate. * * @param type the type to check for, may not be null * @return the predicate * @throws IllegalArgumentException if the class is null */ public static Predicate getInstance(Class type) { if (type == null) { throw new IllegalArgumentException("The type to check instanceof must not be null"); } return new InstanceofPredicate(type); }
/** * Factory method to create a typed map. * <p> * If there are any elements already in the map being decorated, they * are validated. * * @param map the map to decorate, must not be null * @param keyType the type to allow as keys, must not be null * @param valueType the type to allow as values, must not be null * @throws IllegalArgumentException if list or type is null * @throws IllegalArgumentException if the list contains invalid elements */ public static Map decorate(Map map, Class keyType, Class valueType) { return new PredicatedMap( map, InstanceofPredicate.getInstance(keyType), InstanceofPredicate.getInstance(valueType) ); }
/** * Factory to create the identity predicate. * * @param type the type to check for, may not be null * @return the predicate * @throws IllegalArgumentException if the class is null */ public static Predicate getInstance(Class type) { if (type == null) { throw new IllegalArgumentException("The type to check instanceof must not be null"); } return new InstanceofPredicate(type); }
/** * Factory method to create a typed sorted map. * <p> * If there are any elements already in the map being decorated, they * are validated. * * @param map the map to decorate, must not be null * @param keyType the type to allow as keys, must not be null * @param valueType the type to allow as values, must not be null * @throws IllegalArgumentException if list or type is null * @throws IllegalArgumentException if the list contains invalid elements */ public static SortedMap decorate(SortedMap map, Class keyType, Class valueType) { return new PredicatedSortedMap( map, InstanceofPredicate.getInstance(keyType), InstanceofPredicate.getInstance(valueType) ); }
/** * Factory to create the identity predicate. * * @param type the type to check for, may not be null * @return the predicate * @throws IllegalArgumentException if the class is null */ public static Predicate getInstance(Class type) { if (type == null) { throw new IllegalArgumentException("The type to check instanceof must not be null"); } return new InstanceofPredicate(type); }
/** * Factory method to create a typed sorted map. * <p> * If there are any elements already in the map being decorated, they * are validated. * * @param map the map to decorate, must not be null * @param keyType the type to allow as keys, must not be null * @param valueType the type to allow as values, must not be null * @throws IllegalArgumentException if list or type is null * @throws IllegalArgumentException if the list contains invalid elements */ public static SortedMap decorate(SortedMap map, Class keyType, Class valueType) { return new PredicatedSortedMap( map, InstanceofPredicate.getInstance(keyType), InstanceofPredicate.getInstance(valueType) ); }
/** * Factory to create the identity predicate. * * @param type the type to check for, may not be null * @return the predicate * @throws IllegalArgumentException if the class is null */ public static Predicate getInstance(Class type) { if (type == null) { throw new IllegalArgumentException("The type to check instanceof must not be null"); } return new InstanceofPredicate(type); }
/** * Factory method to create a typed map. * <p> * If there are any elements already in the map being decorated, they * are validated. * * @param map the map to decorate, must not be null * @param keyType the type to allow as keys, must not be null * @param valueType the type to allow as values, must not be null * @throws IllegalArgumentException if list or type is null * @throws IllegalArgumentException if the list contains invalid elements */ public static Map decorate(Map map, Class keyType, Class valueType) { return new PredicatedMap( map, InstanceofPredicate.getInstance(keyType), InstanceofPredicate.getInstance(valueType) ); }
/** * Factory to create the identity predicate. * * @param type the type to check for, may not be null * @return the predicate * @throws IllegalArgumentException if the class is null */ public static Predicate getInstance(Class type) { if (type == null) { throw new IllegalArgumentException("The type to check instanceof must not be null"); } return new InstanceofPredicate(type); }
/** * Factory method to create a typed sorted set. * <p> * If there are any elements already in the set being decorated, they * are validated. * * @param set the set to decorate, must not be null * @param type the type to allow into the collection, must not be null * @throws IllegalArgumentException if set or type is null * @throws IllegalArgumentException if the set contains invalid elements */ public static SortedSet decorate(SortedSet set, Class type) { return new PredicatedSortedSet(set, InstanceofPredicate.getInstance(type)); }
/** * Factory to create the identity predicate. * * @param type the type to check for, may not be null * @return the predicate * @throws IllegalArgumentException if the class is null */ public static Predicate getInstance(Class type) { if (type == null) { throw new IllegalArgumentException("The type to check instanceof must not be null"); } return new InstanceofPredicate(type); }
/** * Factory method to create a typed list. * <p> * If there are any elements already in the list being decorated, they * are validated. * * @param list the list to decorate, must not be null * @param type the type to allow into the collection, must not be null * @throws IllegalArgumentException if list or type is null * @throws IllegalArgumentException if the list contains invalid elements */ public static List decorate(List list, Class type) { return new PredicatedList(list, InstanceofPredicate.getInstance(type)); }
@Override @SuppressWarnings("unchecked") public <T> Collection<T> lookupObjects(Class<T> returntype) { return (Collection<T>) registryMap.select(new InstanceofPredicate(returntype)); }
/** * Factory method to create a typed sorted bag. * <p> * If there are any elements already in the bag being decorated, they * are validated. * * @param bag the bag to decorate, must not be null * @param type the type to allow into the bag, must not be null * @return a new transformed SortedBag * @throws IllegalArgumentException if bag or type is null * @throws IllegalArgumentException if the bag contains invalid elements */ public static SortedBag decorate(SortedBag bag, Class type) { return new PredicatedSortedBag(bag, InstanceofPredicate.getInstance(type)); }
@SuppressWarnings("unchecked") public <T> Collection<T> lookupObjects(Class<T> returntype) { return (Collection<T>) registryMap.select(new InstanceofPredicate(returntype)); }
/** * Factory method to create a typed list. * <p> * If there are any elements already in the buffer being decorated, they * are validated. * * @param buffer the buffer to decorate, must not be null * @param type the type to allow into the buffer, must not be null * @return a new typed Buffer * @throws IllegalArgumentException if buffer or type is null * @throws IllegalArgumentException if the buffer contains invalid elements */ public static Buffer decorate(Buffer buffer, Class type) { return new PredicatedBuffer(buffer, InstanceofPredicate.getInstance(type)); }