org.unitils.util
Class CollectionUtils

java.lang.Object
  extended by org.unitils.util.CollectionUtils

public class CollectionUtils
extends Object

Class containing collection related utilities

Author:
Filip Neven, Tim Ducheyne

Constructor Summary
CollectionUtils()
           
 
Method Summary
static
<T> Set<T>
asSet(T... elements)
          Converts the given array of elements to a set.
static Collection<?> convertToCollection(Object object)
          Converts the given array or collection object (possibly primitive array) to type Collection
static Object[] convertToObjectArray(Object object)
          Converts the given array object (possibly primitive array) to type Object[]
static
<T> List<T>
subList(List<T> list, int fromIndex, int toIndex)
          Gets a list containing all elements from the given index to the given index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionUtils

public CollectionUtils()
Method Detail

subList

public static <T> List<T> subList(List<T> list,
                                  int fromIndex,
                                  int toIndex)
Gets a list containing all elements from the given index to the given index.

Parameters:
list - The original list
fromIndex - The from index
toIndex - The to index
Returns:
The sub-list, not null

asSet

public static <T> Set<T> asSet(T... elements)
Converts the given array of elements to a set.

Parameters:
elements - The elements
Returns:
The elements as a set, empty if elements was null

convertToCollection

public static Collection<?> convertToCollection(Object object)
Converts the given array or collection object (possibly primitive array) to type Collection

Parameters:
object - The array or collection
Returns:
The object collection

convertToObjectArray

public static Object[] convertToObjectArray(Object object)
Converts the given array object (possibly primitive array) to type Object[]

Parameters:
object - The array
Returns:
The object array


Copyright © 2011. All Rights Reserved.