class TypedCollections
extends java.lang.Object
| Constructor and Description |
|---|
TypedCollections() |
| Modifier and Type | Method and Description |
|---|---|
private static boolean |
checkCollectionMembers(java.util.Collection<?> c,
java.lang.Class<?> type)
Dynamically check that the members of the collection are all
instances of the given type (or null).
|
(package private) static <E,TypedC extends java.util.Collection<E>> |
dynamicallyCastCollection(java.util.Collection<?> c,
java.lang.Class<E> type,
java.lang.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.
|
(package private) static <E> java.util.List<E> |
dynamicallyCastList(java.util.List<?> list,
java.lang.Class<E> type)
Dynamically check that the members of the list are all instances of
the given type (or null).
|
(package private) static <K,V> java.util.Map<K,V> |
dynamicallyCastMap(java.util.Map<?,?> map,
java.lang.Class<K> keyType,
java.lang.Class<V> valueType)
Dynamically check that the keys and values in the map are all
instances of the correct types (or null).
|
(package private) static <E> java.util.Set<E> |
dynamicallyCastSet(java.util.Set<?> set,
java.lang.Class<E> type)
Dynamically check that the members of the set are all instances of
the given type (or null).
|
private static boolean checkCollectionMembers(java.util.Collection<?> c,
java.lang.Class<?> type)
static <E,TypedC extends java.util.Collection<E>> TypedC dynamicallyCastCollection(java.util.Collection<?> c,
java.lang.Class<E> type,
java.lang.Class<TypedC> collectionType)
E - the collection's element typec - the collection to casttype - the class of the collection's element type.java.lang.ClassCastExceptionstatic <E> java.util.List<E> dynamicallyCastList(java.util.List<?> list,
java.lang.Class<E> type)
E - the list's element typelist - the list to casttype - the class of the list's element type.java.lang.ClassCastExceptionstatic <E> java.util.Set<E> dynamicallyCastSet(java.util.Set<?> set,
java.lang.Class<E> type)
E - the set's element typeset - the set to casttype - the class of the set's element type.java.lang.ClassCastExceptionstatic <K,V> java.util.Map<K,V> dynamicallyCastMap(java.util.Map<?,?> map,
java.lang.Class<K> keyType,
java.lang.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.keyType - the class of the map's key type.java.lang.ClassCastException