Package com.sun.faces.util
Class TypedCollections
java.lang.Object
com.sun.faces.util.TypedCollections
public class TypedCollections extends Object
-
Constructor Summary
Constructors Constructor Description TypedCollections()
-
Method Summary
Modifier and Type Method Description static <E, TypedC extends Collection<E>>
TypedCdynamicallyCastCollection(Collection<?> c, Class<E> type, Class<TypedC> collectionType)
Dynamically check that the members of the collection are all instances of the given type (or null), and that the collection itself is of the given collection type.static <E> List<E>
dynamicallyCastList(List<?> list, Class<E> type)
Dynamically check that the members of the list are all instances of the given type (or null).static <K, V> Map<K,V>
dynamicallyCastMap(Map<?,?> map, Class<K> keyType, Class<V> valueType)
Dynamically check that the keys and values in the map are all instances of the correct types (or null).static <E> Set<E>
dynamicallyCastSet(Set<?> set, Class<E> type)
Dynamically check that the members of the set are all instances of the given type (or null).
-
Constructor Details
-
TypedCollections
public TypedCollections()
-
-
Method Details
-
dynamicallyCastCollection
public static <E, TypedC extends Collection<E>> TypedC dynamicallyCastCollection(Collection<?> c, Class<E> type, Class<TypedC> collectionType)Dynamically check that the members of the collection are all instances of the given type (or null), and that the collection itself is of the given collection type.- Type Parameters:
E
- the collection's element type- Parameters:
c
- the collection to casttype
- the class of the collection's element type.- Returns:
- the dynamically-type checked collection.
- Throws:
ClassCastException
-
dynamicallyCastList
Dynamically check that the members of the list are all instances of the given type (or null).- Type Parameters:
E
- the list's element type- Parameters:
list
- the list to casttype
- the class of the list's element type.- Returns:
- the dynamically-type checked list.
- Throws:
ClassCastException
-
dynamicallyCastSet
Dynamically check that the members of the set are all instances of the given type (or null).- Type Parameters:
E
- the set's element type- Parameters:
set
- the set to casttype
- the class of the set's element type.- Returns:
- the dynamically-type checked set.
- Throws:
ClassCastException
-
dynamicallyCastMap
public static <K, V> Map<K,V> dynamicallyCastMap(Map<?,?> map, Class<K> keyType, Class<V> valueType)Dynamically check that the keys and values in the map are all instances of the correct types (or null).- Type Parameters:
K
- the map's key typeV
- the map's value type- Parameters:
map
- the map to castkeyType
- the class of the map's key type.valueType
- the class of the map's value type.- Returns:
- the dynamically-type checked map.
- Throws:
ClassCastException
-