org.jbpm.util
Class CollectionUtil

java.lang.Object
  extended by org.jbpm.util.CollectionUtil

public class CollectionUtil
extends java.lang.Object

Author:
Alejandro Guizar

Method Summary
static
<E> java.util.Collection<E>
checkCollection(java.util.Collection<?> collection, java.lang.Class<E> type)
          Ensures that all elements of the given collection can be cast to a desired type.
static
<E> java.util.List<E>
checkList(java.util.List<?> list, java.lang.Class<E> type)
          Ensures that all elements of the given list can be cast to a desired type.
static
<K,V> java.util.Map<K,V>
checkMap(java.util.Map<?,?> map, java.lang.Class<K> keyType, java.lang.Class<V> valueType)
           
static
<E> java.util.Set<E>
checkSet(java.util.Set<?> set, java.lang.Class<E> type)
          Ensures that all elements of the given set can be cast to a desired type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

checkCollection

public static <E> java.util.Collection<E> checkCollection(java.util.Collection<?> collection,
                                                          java.lang.Class<E> type)
Ensures that all elements of the given collection can be cast to a desired type.

Parameters:
collection - the collection to check
type - the desired type
Returns:
a collection of the desired type
Throws:
java.lang.ClassCastException - if an element cannot be cast to the desired type

checkList

public static <E> java.util.List<E> checkList(java.util.List<?> list,
                                              java.lang.Class<E> type)
Ensures that all elements of the given list can be cast to a desired type.

Parameters:
list - the list to check
type - the desired type
Returns:
a list of the desired type
Throws:
java.lang.ClassCastException - if an element cannot be cast to the desired type

checkSet

public static <E> java.util.Set<E> checkSet(java.util.Set<?> set,
                                            java.lang.Class<E> type)
Ensures that all elements of the given set can be cast to a desired type.

Parameters:
list - the set to check
type - the desired type
Returns:
a set of the desired type
Throws:
java.lang.ClassCastException - if an element cannot be cast to the desired type

checkMap

public static <K,V> java.util.Map<K,V> checkMap(java.util.Map<?,?> map,
                                                java.lang.Class<K> keyType,
                                                java.lang.Class<V> valueType)


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.