org.hibernate.validator.util
Class CollectionHelper

java.lang.Object
  extended by org.hibernate.validator.util.CollectionHelper

public class CollectionHelper
extends Object

Provides some methods for simplified collection instantiation.

Author:
Gunnar Morling, Kevin Pollet - SERLI - (kevin.pollet@serli.com)

Nested Class Summary
static interface CollectionHelper.Partitioner<K,V>
           
 
Method Summary
static
<T> Set<T>
asSet(T... ts)
           
static
<T> ArrayList<T>
newArrayList()
           
static
<T> ArrayList<T>
newArrayList(int size)
           
static
<T> ArrayList<T>
newArrayList(Iterable<T>... iterables)
           
static
<K,V> HashMap<K,V>
newHashMap()
           
static
<K,V> HashMap<K,V>
newHashMap(int size)
           
static
<T> HashSet<T>
newHashSet()
           
static
<T> HashSet<T>
newHashSet(int size)
           
static
<K,V> Map<K,List<V>>
partition(List<V> list, CollectionHelper.Partitioner<K,V> partitioner)
          Creates a map containing the given list's values partitioned by the given partitioner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newHashMap

public static <K,V> HashMap<K,V> newHashMap()

newHashMap

public static <K,V> HashMap<K,V> newHashMap(int size)

newHashSet

public static <T> HashSet<T> newHashSet()

newHashSet

public static <T> HashSet<T> newHashSet(int size)

newArrayList

public static <T> ArrayList<T> newArrayList()

newArrayList

public static <T> ArrayList<T> newArrayList(int size)

newArrayList

public static <T> ArrayList<T> newArrayList(Iterable<T>... iterables)

asSet

public static <T> Set<T> asSet(T... ts)

partition

public static <K,V> Map<K,List<V>> partition(List<V> list,
                                             CollectionHelper.Partitioner<K,V> partitioner)
Creates a map containing the given list's values partitioned by the given partitioner.

Type Parameters:
K - The key type of the resulting map.
V - The element type of the list to be partitioned.
Parameters:
list - The list to be partitioned.
partitioner - The partitioner to be used for determining the partitions.
Returns:
A map containing the given list's values partitioned by the given partitioner.


Copyright © 2007-2011 Red Hat Middleware, LLC. All Rights Reserved