public final class CollectionFactory extends Object
Mainly for internal use within the framework.
| Modifier and Type | Method and Description | 
|---|---|
| static <E> Collection<E> | createApproximateCollection(Object collection,
                           int capacity)Create the most approximate collection for the given collection. | 
| static <K,V> Map<K,V> | createApproximateMap(Object map,
                    int capacity)Create the most approximate map for the given map. | 
| static <E> Collection<E> | createCollection(Class<?> collectionType,
                Class<?> elementType,
                int capacity)Create the most appropriate collection for the given collection type. | 
| static <E> Collection<E> | createCollection(Class<?> collectionType,
                int capacity)Create the most appropriate collection for the given collection type. | 
| static <K,V> Map<K,V> | createMap(Class<?> mapType,
         Class<?> keyType,
         int capacity)Create the most appropriate map for the given map type. | 
| static <K,V> Map<K,V> | createMap(Class<?> mapType,
         int capacity)Create the most appropriate map for the given map type. | 
| static Properties | createSortedProperties(boolean omitComments)Create a variant of  Propertiesthat sorts properties
 alphanumerically based on their keys. | 
| static Properties | createSortedProperties(Properties properties,
                      boolean omitComments)Create a variant of  Propertiesthat sorts properties
 alphanumerically based on their keys. | 
| static Properties | createStringAdaptingProperties()Create a variant of  Propertiesthat automatically adapts
 non-String values to String representations inProperties.getProperty(java.lang.String). | 
| 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. | 
public static boolean isApproximableCollectionType(@Nullable Class<?> collectionType)
createApproximateCollection(java.lang.Object, int) can approximate.collectionType - the collection type to checktrue if the type is approximablepublic static <E> Collection<E> createApproximateCollection(@Nullable Object collection, int capacity)
Warning: Since the parameterized type E is
 not bound to the type of elements contained in the supplied
 collection, type safety cannot be guaranteed if the supplied
 collection is an EnumSet. In such scenarios, the caller
 is responsible for ensuring that the element type for the supplied
 collection is an enum type matching type E. As an
 alternative, the caller may wish to treat the return value as a raw
 collection or collection of Object.
collection - the original collection object, potentially nullcapacity - the initial capacityisApproximableCollectionType(java.lang.Class<?>), 
LinkedList, 
ArrayList, 
EnumSet, 
TreeSet, 
LinkedHashSetpublic static <E> Collection<E> createCollection(Class<?> collectionType, int capacity)
Delegates to createCollection(Class, Class, int) with a
 null element type.
collectionType - the desired type of the target collection (never null)capacity - the initial capacityIllegalArgumentException - if the supplied collectionType
 is null or of type EnumSetpublic static <E> Collection<E> createCollection(Class<?> collectionType, @Nullable Class<?> elementType, int capacity)
Warning: Since the parameterized type E is
 not bound to the supplied elementType, type safety cannot be
 guaranteed if the desired collectionType is EnumSet.
 In such scenarios, the caller is responsible for ensuring that the
 supplied elementType is an enum type matching type E.
 As an alternative, the caller may wish to treat the return value as a
 raw collection or collection of Object.
collectionType - the desired type of the target collection (never null)elementType - the collection's element type, or null if unknown
 (note: only relevant for EnumSet creation)capacity - the initial capacityIllegalArgumentException - if the supplied collectionType is
 null; or if the desired collectionType is EnumSet and
 the supplied elementType is not a subtype of EnumLinkedHashSet, 
ArrayList, 
TreeSet, 
EnumSetpublic static boolean isApproximableMapType(@Nullable Class<?> mapType)
createApproximateMap(java.lang.Object, int) can approximate.mapType - the map type to checktrue if the type is approximablepublic static <K,V> Map<K,V> createApproximateMap(@Nullable Object map, int capacity)
Warning: Since the parameterized type K is
 not bound to the type of keys contained in the supplied map,
 type safety cannot be guaranteed if the supplied map is an
 EnumMap. In such scenarios, the caller is responsible for
 ensuring that the key type in the supplied map is an enum type
 matching type K. As an alternative, the caller may wish to
 treat the return value as a raw map or map keyed by Object.
map - the original map object, potentially nullcapacity - the initial capacityisApproximableMapType(java.lang.Class<?>), 
EnumMap, 
TreeMap, 
LinkedHashMappublic static <K,V> Map<K,V> createMap(Class<?> mapType, int capacity)
Delegates to createMap(Class, Class, int) with a
 null key type.
mapType - the desired type of the target mapcapacity - the initial capacityIllegalArgumentException - if the supplied mapType is
 null or of type EnumMappublic static <K,V> Map<K,V> createMap(Class<?> mapType, @Nullable Class<?> keyType, int capacity)
Warning: Since the parameterized type K
 is not bound to the supplied keyType, type safety cannot be
 guaranteed if the desired mapType is EnumMap. In such
 scenarios, the caller is responsible for ensuring that the keyType
 is an enum type matching type K. As an alternative, the caller
 may wish to treat the return value as a raw map or map keyed by
 Object. Similarly, type safety cannot be enforced if the
 desired mapType is MultiValueMap.
mapType - the desired type of the target map (never null)keyType - the map's key type, or null if unknown
 (note: only relevant for EnumMap creation)capacity - the initial capacityIllegalArgumentException - if the supplied mapType is
 null; or if the desired mapType is EnumMap and
 the supplied keyType is not a subtype of EnumLinkedHashMap, 
TreeMap, 
LinkedMultiValueMap, 
EnumMappublic static Properties createStringAdaptingProperties()
Properties that automatically adapts
 non-String values to String representations in Properties.getProperty(java.lang.String).
 In addition, the returned Properties instance sorts properties
 alphanumerically based on their keys.
Properties instancecreateSortedProperties(boolean), 
createSortedProperties(Properties, boolean)public static Properties createSortedProperties(boolean omitComments)
Properties that sorts properties
 alphanumerically based on their keys.
 This can be useful when storing the Properties instance in a
 properties file, since it allows such files to be generated in a repeatable
 manner with consistent ordering of properties. Comments in generated
 properties files can also be optionally omitted.
omitComments - true if comments should be omitted when
 storing properties in a fileProperties instancecreateStringAdaptingProperties(), 
createSortedProperties(Properties, boolean)public static Properties createSortedProperties(Properties properties, boolean omitComments)
Properties that sorts properties
 alphanumerically based on their keys.
 This can be useful when storing the Properties instance in a
 properties file, since it allows such files to be generated in a repeatable
 manner with consistent ordering of properties. Comments in generated
 properties files can also be optionally omitted.
 
The returned Properties instance will be populated with
 properties from the supplied properties object, but default
 properties from the supplied properties object will not be copied.
properties - the Properties object from which to copy the
 initial propertiesomitComments - true if comments should be omitted when
 storing properties in a fileProperties instancecreateStringAdaptingProperties(), 
createSortedProperties(boolean)