/** * 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 java.util.Map <Object, Object> decorate(java.util.Map <Object, Object> map, java.lang.Class keyType, java.lang.Class valueType) { return(new PredicatedMap( map, InstanceofPredicate.getInstance(keyType), InstanceofPredicate.getInstance(valueType) )); }
/** * 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 java.util.SortedSet <Object> decorate(java.util.SortedSet <Object> set, java.lang.Class type) { return(new PredicatedSortedSet(set, InstanceofPredicate.getInstance(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(Type type) { return(InstanceofPredicate.getInstance(type)); }
/** * 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, java.lang.Class type) { return(new PredicatedBuffer(buffer, InstanceofPredicate.getInstance(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 java.util.List <Object> decorate(java.util.List <Object> list, java.lang.Class type) { return(new PredicatedList(list, InstanceofPredicate.getInstance(type))); }
/** * Factory method to create a typed 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 typed Bag * @throws IllegalArgumentException if bag or type is null * @throws IllegalArgumentException if the bag contains invalid elements */ public static Bag decorate(Bag bag, java.lang.Class type) { return(new PredicatedBag(bag, InstanceofPredicate.getInstance(type))); }
/** * Factory method to create a typed collection. * <p> * If there are any elements already in the collection being decorated, they * are validated. * * @param coll the collection to decorate, must not be null * @param type the type to allow into the collection, must not be null * @return a new typed collection * @throws IllegalArgumentException if collection or type is null * @throws IllegalArgumentException if the collection contains invalid elements */ public static java.util.Collection <Object> decorate(java.util.Collection <Object> coll, java.lang.Class type) { return(new PredicatedCollection(coll, InstanceofPredicate.getInstance(type))); }