public abstract class CollectionFactory extends 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 Collection |
createApproximateCollection(Object collection,
int initialCapacity)
Create the most approximate collection for the given collection.
|
static Map |
createApproximateMap(Object map,
int initialCapacity)
Create the most approximate map for the given map.
|
static Collection |
createCollection(Class<?> collectionType,
int initialCapacity)
Create the most appropriate collection for the given collection type.
|
static ConcurrentMap |
createConcurrentMap(int initialCapacity)
Deprecated.
as of Spring 3.0, for usage on JDK 1.5 or higher
|
static Map |
createConcurrentMapIfPossible(int initialCapacity)
Deprecated.
as of Spring 3.0, for usage on JDK 1.5 or higher
|
static <T> Set<T> |
createCopyOnWriteSet()
Deprecated.
as of Spring 3.0, for usage on JDK 1.5 or higher
|
static Map |
createIdentityMapIfPossible(int initialCapacity)
Deprecated.
as of Spring 2.5, for usage on JDK 1.4 or higher
|
static Map |
createLinkedCaseInsensitiveMapIfPossible(int initialCapacity)
Deprecated.
as of Spring 3.0, for usage on JDK 1.5 or higher
|
static <K,V> Map<K,V> |
createLinkedMapIfPossible(int initialCapacity)
Deprecated.
as of Spring 2.5, for usage on JDK 1.4 or higher
|
static <T> Set<T> |
createLinkedSetIfPossible(int initialCapacity)
Deprecated.
as of Spring 2.5, for usage on JDK 1.4 or higher
|
static Map |
createMap(Class<?> mapType,
int initialCapacity)
Create the most approximate map for the given map.
|
static boolean |
isApproximableCollectionType(Class<?> collectionType)
Determine whether the given collection type is an approximable type,
i.e.
|
static boolean |
isApproximableMapType(Class<?> mapType)
Determine whether the given map type is an approximable type,
i.e.
|
@Deprecated public static <T> Set<T> createLinkedSetIfPossible(int initialCapacity)
LinkedHashSet
, since Spring 2.5
requires JDK 1.4 anyway.initialCapacity
- the initial capacity of the Set@Deprecated public static <T> Set<T> createCopyOnWriteSet()
CopyOnWriteArraySet
,
since Spring 3 requires JDK 1.5 anyway.@Deprecated public static <K,V> Map<K,V> createLinkedMapIfPossible(int initialCapacity)
LinkedHashMap
, since Spring 2.5
requires JDK 1.4 anyway.initialCapacity
- the initial capacity of the Map@Deprecated public static Map createLinkedCaseInsensitiveMapIfPossible(int initialCapacity)
LinkedCaseInsensitiveMap
.initialCapacity
- the initial capacity of the Map@Deprecated public static Map createIdentityMapIfPossible(int initialCapacity)
IdentityHashMap
, since Spring 2.5
requires JDK 1.4 anyway.initialCapacity
- the initial capacity of the Map@Deprecated public static Map createConcurrentMapIfPossible(int initialCapacity)
ConcurrentHashMap
, since Spring 3.0
requires JDK 1.5 anyway.initialCapacity
- the initial capacity of the Map@Deprecated public static ConcurrentMap createConcurrentMap(int initialCapacity)
ConcurrentMap
interface:
This implementation always creates a ConcurrentHashMap
,
since Spring 3.0 requires JDK 1.5 anyway.initialCapacity
- the initial capacity of the Mappublic static boolean isApproximableCollectionType(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 Collection createApproximateCollection(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
,
LinkedHashSet
public static Collection createCollection(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
,
LinkedHashSet
public static boolean isApproximableMapType(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 Map createApproximateMap(Object map, int initialCapacity)
Creates a TreeMap or linked Map for a SortedMap or Map, respectively.
map
- the original Map objectinitialCapacity
- the initial capacityTreeMap
,
LinkedHashMap
public static Map createMap(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