public final class CollectionFactory extends Object
Map<Foo, Bar> map = newMap();This is a replacement for:
Map<Foo, Bar> map = new HashMap<Foo, Bar>();
Constructor and Description |
---|
CollectionFactory() |
Modifier and Type | Method and Description |
---|---|
static <V> Map<String,V> |
newCaseInsensitiveMap() |
static <K,V> ConcurrentMap<K,V> |
newConcurrentMap()
Constructs a new concurrent map, which is safe to access via multiple threads.
|
static <T> LinkedList<T> |
newLinkedList()
Useful for queues.
|
static <T> List<T> |
newList()
Contructs and returns a new generic
ArrayList instance. |
static <T,V extends T> |
newList(Collection<V> list)
Constructs and returns a new
ArrayList as a copy of the provided collection. |
static <T,V extends T> |
newList(V... elements)
Creates a new, fully modifiable list from an initial set of elements.
|
static <K,V> Map<K,V> |
newMap()
Constructs and returns a generic
HashMap instance. |
static <K,V> Map<K,V> |
newMap(Map<? extends K,? extends V> map)
Constructs a new
HashMap instance by copying an existing Map instance. |
static <T> Set<T> |
newSet()
Constructs and returns a generic
HashSet instance. |
static <T,V extends T> |
newSet(Collection<V> values)
Contructs a new
HashSet and initializes it using the provided collection. |
static <T,V extends T> |
newSet(V... values) |
static <T> Stack<T> |
newStack() |
static <T> List<T> |
newThreadSafeList()
Constructs and returns a new
CopyOnWriteArrayList . |
public CollectionFactory()
public static <T,V extends T> Set<T> newSet(Collection<V> values)
HashSet
and initializes it using the provided collection.public static <K,V> Map<K,V> newMap(Map<? extends K,? extends V> map)
HashMap
instance by copying an existing Map instance.public static <K,V> ConcurrentMap<K,V> newConcurrentMap()
public static <T,V extends T> List<T> newList(V... elements)
public static <T> LinkedList<T> newLinkedList()
public static <T,V extends T> List<T> newList(Collection<V> list)
ArrayList
as a copy of the provided collection.public static <T> List<T> newThreadSafeList()
CopyOnWriteArrayList
.public static <V> Map<String,V> newCaseInsensitiveMap()
5.6.3 - Copyright © 2003-2021 The Apache Software Foundation.