public class TypedCollections extends Object
| Constructor and Description |
|---|
TypedCollections() |
| Modifier and Type | Method and Description |
|---|---|
static <E,TypedC extends Collection<E>> |
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.
|
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).
|
public static <E,TypedC extends Collection<E>> TypedC dynamicallyCastCollection(Collection<?> c, Class<E> type, Class<TypedC> collectionType)
E - the collection's element typec - the collection to casttype - the class of the collection's element type.ClassCastExceptionpublic static <E> List<E> dynamicallyCastList(List<?> list, Class<E> type)
E - the list's element typelist - the list to casttype - the class of the list's element type.ClassCastExceptionpublic static <E> Set<E> dynamicallyCastSet(Set<?> set, Class<E> type)
E - the set's element typeset - the set to casttype - the class of the set's element type.ClassCastExceptionpublic static <K,V> Map<K,V> dynamicallyCastMap(Map<?,?> map, Class<K> keyType, Class<V> valueType)
K - the map's key typeV - the map's value typemap - the map to castkeyType - the class of the map's key type.valueType - the class of the map's value type.ClassCastExceptionCopyright © 2010–2019 JBoss by Red Hat. All rights reserved.