public abstract class CollectionFactory
extends java.lang.Object
The goal of this class is to avoid runtime dependencies on a specific Java version, while nevertheless using the best collection implementation that is available at runtime.
| Constructor and Description |
|---|
CollectionFactory() |
| Modifier and Type | Method and Description |
|---|---|
static java.util.Collection |
createApproximateCollection(java.lang.Object collection,
int initialCapacity)
Create the most approximate collection for the given collection.
|
static java.util.Map |
createApproximateMap(java.lang.Object map,
int initialCapacity)
Create the most approximate map for the given map.
|
static java.util.Collection |
createCollection(java.lang.Class<?> collectionType,
int initialCapacity)
Create the most appropriate collection for the given collection type.
|
static ConcurrentMap |
createConcurrentMap(int initialCapacity)
Deprecated.
|
static java.util.Map |
createConcurrentMapIfPossible(int initialCapacity)
Deprecated.
|
static <T> java.util.Set<T> |
createCopyOnWriteSet()
Deprecated.
|
static java.util.Map |
createIdentityMapIfPossible(int initialCapacity)
Deprecated.
|
static java.util.Map |
createLinkedCaseInsensitiveMapIfPossible(int initialCapacity)
Deprecated.
|
static <K,V> java.util.Map<K,V> |
createLinkedMapIfPossible(int initialCapacity)
Deprecated.
|
static <T> java.util.Set<T> |
createLinkedSetIfPossible(int initialCapacity)
Deprecated.
|
static java.util.Map |
createMap(java.lang.Class<?> mapType,
int initialCapacity)
Create the most approximate map for the given map.
|
static boolean |
isApproximableCollectionType(java.lang.Class<?> collectionType)
Determine whether the given collection type is an approximable type,
i.e.
|
static boolean |
isApproximableMapType(java.lang.Class<?> mapType)
Determine whether the given map type is an approximable type,
i.e.
|
@Deprecated public static <T> java.util.Set<T> createLinkedSetIfPossible(int initialCapacity)
LinkedHashSet.initialCapacity - the initial capacity of the Set@Deprecated public static <T> java.util.Set<T> createCopyOnWriteSet()
CopyOnWriteArraySet.@Deprecated public static <K,V> java.util.Map<K,V> createLinkedMapIfPossible(int initialCapacity)
LinkedHashMap.initialCapacity - the initial capacity of the Map@Deprecated public static java.util.Map createLinkedCaseInsensitiveMapIfPossible(int initialCapacity)
LinkedCaseInsensitiveMap.initialCapacity - the initial capacity of the Map@Deprecated public static java.util.Map createIdentityMapIfPossible(int initialCapacity)
IdentityHashMap.initialCapacity - the initial capacity of the Map@Deprecated public static java.util.Map createConcurrentMapIfPossible(int initialCapacity)
ConcurrentHashMap.initialCapacity - the initial capacity of the Map@Deprecated public static ConcurrentMap createConcurrentMap(int initialCapacity)
ConcurrentMap interface:
This implementation always creates a ConcurrentHashMap.initialCapacity - the initial capacity of the Mappublic static boolean isApproximableCollectionType(java.lang.Class<?> collectionType)
createApproximateCollection(java.lang.Object, int) can approximate.collectionType - the collection type to checktrue if the type is approximable,
false if it is notpublic static java.util.Collection createApproximateCollection(java.lang.Object collection,
int initialCapacity)
Creates an ArrayList, TreeSet or linked Set for a List, SortedSet or Set, respectively.
collection - the original Collection objectinitialCapacity - the initial capacityArrayList,
TreeSet,
LinkedHashSetpublic static java.util.Collection createCollection(java.lang.Class<?> collectionType,
int initialCapacity)
Creates an ArrayList, TreeSet or linked Set for a List, SortedSet or Set, respectively.
collectionType - the desired type of the target CollectioninitialCapacity - the initial capacityArrayList,
TreeSet,
LinkedHashSetpublic static boolean isApproximableMapType(java.lang.Class<?> mapType)
createApproximateMap(java.lang.Object, int) can approximate.mapType - the map type to checktrue if the type is approximable,
false if it is notpublic static java.util.Map createApproximateMap(java.lang.Object map,
int initialCapacity)
Creates a TreeMap or linked Map for a SortedMap or Map, respectively.
map - the original Map objectinitialCapacity - the initial capacityTreeMap,
LinkedHashMappublic static java.util.Map createMap(java.lang.Class<?> mapType,
int initialCapacity)
Creates a TreeMap or linked Map for a SortedMap or Map, respectively.
mapType - the desired type of the target MapinitialCapacity - the initial capacityTreeMap,
LinkedHashMap