Top Constructors Methods
com.sun.faces.util

public Class TypedCollections

extends Object
Class Inheritance
Imports
java.util.Collection, .List, .Map, .Set

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static boolean
checkCollectionMembers(Collection<?> c, Class<?> type)

Dynamically check that the members of the collection are all instances of the given type (or null).

public static <
the collection's element type
E
, TypedC extends Collection<E>>
TypedC

Returns:

the dynamically-type checked collection.
dynamicallyCastCollection
(Collection<?>
the collection to cast
c
,
Class<E>
the class of the collection's element type.
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.

public static <
the list's element type
E
>
List<E>

Returns:

the dynamically-type checked list.
dynamicallyCastList
(List<?>
the list to cast
list
,
Class<E>
the class of the list's element type.
type
)

Dynamically check that the members of the list are all instances of the given type (or null).

public static <
the map's key type
K
,
the map's value type
V
>
Map<K, V>

Returns:

the dynamically-type checked map.
dynamicallyCastMap
(Map<?, ?>
the map to cast
map
,
Class<K>
the class of the map's key type.
keyType
,
Class<V>
the class of the map's value type.
valueType
)

Dynamically check that the keys and values in the map are all instances of the correct types (or null).

public static <
the set's element type
E
>
Set<E>

Returns:

the dynamically-type checked set.
dynamicallyCastSet
(Set<?>
the set to cast
set
,
Class<E>
the class of the set's element type.
type
)

Dynamically check that the members of the set are all instances of the given type (or null).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

TypedCollectionsback to summary
public TypedCollections()

Method Detail

checkCollectionMembersback to summary
private static boolean checkCollectionMembers(Collection<?> c, Class<?> type)

Dynamically check that the members of the collection are all instances of the given type (or null).

dynamicallyCastCollectionback to summary
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.

Parameters
<E>
the collection's element type
c:Collection<?>

the collection to cast

type:Class<E>

the class of the collection's element type.

Returns:TypedC

the dynamically-type checked collection.

dynamicallyCastListback to summary
public 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).

Parameters
<E>
the list's element type
list:List<?>

the list to cast

type:Class<E>

the class of the list's element type.

Returns:List<E>

the dynamically-type checked list.

Annotations
@SuppressWarnings:unchecked
dynamicallyCastMapback to summary
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).

Parameters
<K>
the map's key type
<V>
the map's value type
map:Map<?, ?>

the map to cast

keyType:Class<K>

the class of the map's key type.

valueType:Class<V>

the class of the map's value type.

Returns:Map<K, V>

the dynamically-type checked map.

Annotations
@SuppressWarnings:unchecked
dynamicallyCastSetback to summary
public 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).

Parameters
<E>
the set's element type
set:Set<?>

the set to cast

type:Class<E>

the class of the set's element type.

Returns:Set<E>

the dynamically-type checked set.

Annotations
@SuppressWarnings:unchecked