com.sun.faces.util
Class TypedCollections

java.lang.Object
  extended by com.sun.faces.util.TypedCollections

public class TypedCollections
extends java.lang.Object


Constructor Summary
TypedCollections()
           
 
Method Summary
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).
static
<E,TypedC extends java.util.Collection<E>>
TypedC
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.
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).
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).
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).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TypedCollections

public TypedCollections()
Method Detail

checkCollectionMembers

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).


dynamicallyCastCollection

public static <E,TypedC extends java.util.Collection<E>> TypedC 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.

Type Parameters:
E - the collection's element type
Parameters:
c - the collection to cast
type - the class of the collection's element type.
Returns:
the dynamically-type checked collection.
Throws:
java.lang.ClassCastException

dynamicallyCastList

public 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).

Type Parameters:
E - the list's element type
Parameters:
list - the list to cast
type - the class of the list's element type.
Returns:
the dynamically-type checked list.
Throws:
java.lang.ClassCastException

dynamicallyCastSet

public 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).

Type Parameters:
E - the set's element type
Parameters:
set - the set to cast
type - the class of the set's element type.
Returns:
the dynamically-type checked set.
Throws:
java.lang.ClassCastException

dynamicallyCastMap

public 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).

Type Parameters:
K - the map's key type
V - the map's value type
Parameters:
map - the map to cast
keyType - the class of the map's key type.
keyType - the class of the map's key type.
Returns:
the dynamically-type checked map.
Throws:
java.lang.ClassCastException


Copyright 2002-2011 Oracle America, Inc. All Rights Reserved.