Map and SortedMap instances.
It contains various type safe methods as well as other useful features like deep copying.
It also provides the following decorators:
fixedSizeMap(Map)
fixedSizeSortedMap(SortedMap)
lazyMap(Map, Factory)
lazyMap(Map, Transformer)
lazySortedMap(SortedMap, Factory)
lazySortedMap(SortedMap, Transformer)
predicatedMap(Map, Predicate, Predicate)
predicatedSortedMap(SortedMap, Predicate, Predicate)
transformedMap(Map, Transformer, Transformer)
transformedSortedMap(SortedMap, Transformer, Transformer)
multiValueMap(Map)
multiValueMap(Map, Class)
multiValueMap(Map, Factory)
| Modifier and Type | Field and Description |
|---|---|
| public static final SortedMap | EMPTY_SORTED_MAP
An empty unmodifiable sorted map. |
| private static final String | INDENT_STRING
String used to indent the verbose and debug Map prints. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static void | debugPrint(final PrintStream
the stream to print to, must not be null out, final Object The label to be used, may be label, final Map<?, ?> null.
If null, the label is not output.
It typically represents the name of the property in a bean or similar.The map to print, may be map)null.
If null, the text 'null' is output.Prints the given map with nice line breaks. |
| public static < the key type K, the value type V> Map | Returns: an empty map if the argument isnullthe map, possibly map)nullReturns an immutable empty map if the argument is |
| public static < the key type K, the value type V> IterableMap | Returns: a fixed-size map backed by that mapthe map whose size to fix, must not be null map)Returns a fixed-sized map backed by the given map. |
| public static < the key type K, the value type V> SortedMap | Returns: a fixed-size map backed by that mapthe map whose size to fix, must not be null map)Returns a fixed-sized sorted map backed by the given sorted map. |
| public static < the key type K> Boolean | Returns: the value in the Map as a Boolean,null if null map inputthe map to use map, final K the key to look up key)Gets a Boolean from a Map in a null-safe manner. |
| public static < the key type K> Boolean | Returns: the value in the map as a boolean, or defaultValue if the original value is null, the map is null or the boolean conversion failsthe map whose value to look up map, final K the key of the value to look up in that map key, final Boolean what to return if the value is null or if the
conversion fails defaultValue)Looks up the given key in the given map, converting the result into a boolean, using the default value if the conversion fails. |
| public static < the key type K> boolean | Returns: the value in the Map as a Boolean,false if null map inputthe map to use map, final K the key to look up key)Gets a boolean from a Map in a null-safe manner. |
| public static < the key type K> boolean | Returns: the value in the Map as a Boolean,defaultValue if null map inputthe map to use map, final K the key to look up key, final boolean return if the value is null or if the conversion fails defaultValue)Gets a boolean from a Map in a null-safe manner, using the default value if the conversion fails. |
| public static < the key type K> Byte | |
| public static < the key type K> Byte | Returns: the value in the map as a number, or defaultValue if the original value is null, the map is null or the number conversion failsthe map whose value to look up map, final K the key of the value to look up in that map key, final Byte what to return if the value is null or if the
conversion fails defaultValue)Looks up the given key in the given map, converting the result into a byte, using the default value if the conversion fails. |
| public static < the key type K> byte | Returns: the value in the Map as a byte,0 if null map inputthe map to use map, final K the key to look up key)Gets a byte from a Map in a null-safe manner. |
| public static < the key type K> byte | Returns: the value in the Map as a byte,defaultValue if null map inputthe map to use map, final K the key to look up key, final byte return if the value is null or if the conversion fails defaultValue)Gets a byte from a Map in a null-safe manner, using the default value if the conversion fails. |
| public static < the key type K> Double | |
| public static < the key type K> Double | Returns: the value in the map as a number, or defaultValue if the original value is null, the map is null or the number conversion failsthe map whose value to look up map, final K the key of the value to look up in that map key, final Double what to return if the value is null or if the
conversion fails defaultValue)Looks up the given key in the given map, converting the result into a double, using the default value if the conversion fails. |
| public static < the key type K> double | Returns: the value in the Map as a double,0.0 if null map inputthe map to use map, final K the key to look up key)Gets a double from a Map in a null-safe manner. |
| public static < the key type K> double | Returns: the value in the Map as a double,defaultValue if null map inputthe map to use map, final K the key to look up key, final double return if the value is null or if the conversion fails defaultValue)Gets a double from a Map in a null-safe manner, using the default value if the conversion fails. |
| public static < the key type K> Float | |
| public static < the key type K> Float | Returns: the value in the map as a number, or defaultValue if the original value is null, the map is null or the number conversion failsthe map whose value to look up map, final K the key of the value to look up in that map key, final Float what to return if the value is null or if the
conversion fails defaultValue)Looks up the given key in the given map, converting the result into a float, using the default value if the conversion fails. |
| public static < the key type K> float | Returns: the value in the Map as a float,0.0F if null map inputthe map to use map, final K the key to look up key)Gets a float from a Map in a null-safe manner. |
| public static < the key type K> float | Returns: the value in the Map as a float,defaultValue if null map inputthe map to use map, final K the key to look up key, final float return if the value is null or if the conversion fails defaultValue)Gets a float from a Map in a null-safe manner, using the default value if the conversion fails. |
| public static < the key type K> Integer | Returns: the value in the Map as a Integer,null if null map inputthe map to use map, final K the key to look up key)Gets a Integer from a Map in a null-safe manner. |
| public static < the key type K> Integer | Returns: the value in the map as a number, or defaultValue if the original value is null, the map is null or the number conversion failsthe map whose value to look up map, final K the key of the value to look up in that map key, final Integer what to return if the value is null or if the
conversion fails defaultValue)Looks up the given key in the given map, converting the result into an integer, using the default value if the conversion fails. |
| public static < the key type K> int | Returns: the value in the Map as an int,0 if null map inputthe map to use map, final K the key to look up key)Gets an int from a Map in a null-safe manner. |
| public static < the key type K> int | Returns: the value in the Map as an int,defaultValue if null map inputthe map to use map, final K the key to look up key, final int return if the value is null or if the conversion fails defaultValue)Gets an int from a Map in a null-safe manner, using the default value if the conversion fails. |
| public static < the key type K> Long | |
| public static < the key type K> Long | Returns: the value in the map as a number, or defaultValue if the original value is null, the map is null or the number conversion failsthe map whose value to look up map, final K the key of the value to look up in that map key, final Long what to return if the value is null or if the
conversion fails defaultValue)Looks up the given key in the given map, converting the result into a long, using the default value if the conversion fails. |
| public static < the key type K> long | Returns: the value in the Map as a long,0L if null map inputthe map to use map, final K the key to look up key)Gets a long from a Map in a null-safe manner. |
| public static < the key type K> long | Returns: the value in the Map as a long,defaultValue if null map inputthe map to use map, final K the key to look up key, final long return if the value is null or if the conversion fails defaultValue)Gets a long from a Map in a null-safe manner, using the default value if the conversion fails. |
| public static < the key type K> Map | |
| public static < the key type K> Map | Returns: the value in the map as a number, or defaultValue if the original value is null, the map is null or the map conversion failsthe map whose value to look up map, final K the key of the value to look up in that map key, final Map<?, ?> what to return if the value is null or if the
conversion fails defaultValue)Looks up the given key in the given map, converting the result into a map, using the default value if the conversion fails. |
| public static < the key type K> Number | |
| public static < the key type K> Number | Returns: the value in the map as a number, or defaultValue if the original value is null, the map is null or the number conversion failsthe map whose value to look up map, final K the key of the value to look up in that map key, final Number what to return if the value is null or if the
conversion fails defaultValue)Looks up the given key in the given map, converting the result into a number, using the default value if the conversion fails. |
| public static < the key type K, the value type V> V | |
| public static < the key type K, the value type V> V | Returns: the value in the map, or defaultValue if the original value is null or the map is nullthe map whose value to look up map, final K the key of the value to look up in that map key, final V what to return if the value is null defaultValue)Looks up the given key in the given map, converting null into the given default value. |
| public static < the key type K> Short | |
| public static < the key type K> Short | Returns: the value in the map as a number, or defaultValue if the original value is null, the map is null or the number conversion failsthe map whose value to look up map, final K the key of the value to look up in that map key, final Short what to return if the value is null or if the
conversion fails defaultValue)Looks up the given key in the given map, converting the result into a short, using the default value if the conversion fails. |
| public static < the key type K> short | Returns: the value in the Map as a short,0 if null map inputthe map to use map, final K the key to look up key)Gets a short from a Map in a null-safe manner. |
| public static < the key type K> short | Returns: the value in the Map as a short,defaultValue if null map inputthe map to use map, final K the key to look up key, final short return if the value is null or if the conversion fails defaultValue)Gets a short from a Map in a null-safe manner, using the default value if the conversion fails. |
| public static < the key type K> String | |
| public static < the key type K> String | Returns: the value in the map as a string, or defaultValue if the original value is null, the map is null or the string conversion failsthe map whose value to look up map, final K the key of the value to look up in that map key, final String what to return if the value is null or if the
conversion fails defaultValue)Looks up the given key in the given map, converting the result into a string, using the default value if the conversion fails. |
| public static < the key type K, the value type V> Map | |
| public static boolean | |
| public static boolean | Returns: true if non-null and non-emptythe map to check, may be null map)Null-safe check if the specified map is not empty. |
| public static < the key type K, the value type V> IterableMap | Returns: IterableMap<K, V>to wrap if necessary. map)Get the specified |
| public static < the key type K, the value type V> IterableSortedMap | Returns: IterableSortedMap<K, V>to wrap if necessary sortedMap)Get the specified |
| public static < the key type K, the value type V> IterableMap | |
| public static < the key type K, the value type V> IterableMap | Returns: a lazy map backed by the given mapthe map to make lazy, must not be null map, final Transformer<? super K, ? extends V> the factory for creating new objects, must not be null transformerFactory)Returns a "lazy" map whose values will be created on demand. |
| public static < the key type K, the value type V> SortedMap | Returns: a lazy map backed by the given mapthe map to make lazy, must not be null map, final Factory<? extends V> the factory for creating new objects, must not be null factory)Returns a "lazy" sorted map whose values will be created on demand. |
| public static < the key type K, the value type V> SortedMap | Returns: a lazy map backed by the given mapthe map to make lazy, must not be null map, final Transformer<? super K, ? extends V> the factory for creating new objects, must not be null transformerFactory)Returns a "lazy" sorted map whose values will be created on demand. |
| public static < the key type K, the value type V> MultiValueMap | Returns: a multi-value map backed by the given map which returns ArrayLists of values.the map to decorate map)
Deprecated
since 4.1, use
Creates a mult-value map backed by the given map which returns
collections of type ArrayList.
MultiValuedMap instead
|
| public static < the key type K, the value type V, the collection class type C extends Collection | Returns: a multi-value map backed by the given map which returns collections of the specified typethe map to decorate map, final Class<C> the type of collections to return from the map
(must contain public no-arg constructor and extend Collection) collectionClass)
Deprecated
since 4.1, use
Creates a multi-value map backed by the given map which returns
collections of the specified type.
MultiValuedMap instead
|
| public static < the key type K, the value type V, the collection class type C extends Collection | Returns: a multi-value map backed by the given map which returns collections created by the specified collection factorythe map to decorate map, final Factory<C> a factor which creates collection objects collectionFactory)
Deprecated
since 4.1, use
Creates a multi-value map backed by the given map which returns
collections created by the specified collection factory.
MultiValuedMap instead
|
| public static < the key type K, the value type V> OrderedMap | Returns: an ordered map backed by the given mapthe map to order, must not be null map)Returns a map that maintains the order of keys that are added backed by the given map. |
| public static < the key type K, the value type V> void | populateMap(final Map<K, V>
the map, final Iterable<? extends V> Map to populate.the elements, final Transformer<V, K> Iterable containing the input values for the map.the keyTransformer)Transformer used to transform the element into a key valuePopulates a Map using the supplied |
| public static < the key type K, the value type V, the type of object contained in the E> voidIterable | populateMap(final Map<K, V>
the map, final Iterable<? extends E> Map to populate.the elements, final Transformer<E, K> Iterable containing the input values for the map.the keyTransformer, final Transformer<E, V> Transformer used to transform the element into a key valuethe valueTransformer)Transformer used to transform the element into a valuePopulates a Map using the supplied |
| public static < the key type K, the value type V> void | populateMap(final MultiMap<K, V>
the map, final Iterable<? extends V> MultiMap to populate.the elements, final Transformer<V, K> Iterable to use as input values for the map.the keyTransformer)Transformer used to transform the element into a key value
Deprecated
as a consequence of
Populates a MultiMap using the supplied MultiMap being deprecated.
Transformer to transform the elements
into keys, using the unaltered element as the value in the MultiMap.
|
| public static < the key type K, the value type V, the type of object contained in the E> voidIterable | populateMap(final MultiMap<K, V>
the map, final Iterable<? extends E> MultiMap to populate.the elements, final Transformer<E, K> Iterable containing the input values for the map.the keyTransformer, final Transformer<E, V> Transformer used to transform the element into a key valuethe valueTransformer)Transformer used to transform the element into a value
Deprecated
as a consequence of
Populates a MultiMap using the supplied MultiMap being deprecated.
Transformers to transform the elements
into keys and values.
|
| public static < the key type K, the value type V> IterableMap | Returns: a predicated map backed by the given mapthe map to predicate, must not be null map, final Predicate<? super K> the predicate for keys, null means no check keyPred, final Predicate<? super V> the predicate for values, null means no check valuePred)Returns a predicated (validating) map backed by the given map. |
| public static < the key type K, the value type V> SortedMap | Returns: a predicated map backed by the given mapthe map to predicate, must not be null map, final Predicate<? super K> the predicate for keys, null means no check keyPred, final Predicate<? super V> the predicate for values, null means no check valuePred)Returns a predicated (validating) sorted map backed by the given map. |
| private static void | printIndent(final PrintStream
the stream to indent out, final int indent)Writes indentation to the given stream. |
| public static < the key type K, the value type V> Map | |
| public static < the key type K> void | safeAddToMap(final Map<? super K, Object>
the map to add to, may not be null map, final K the key key, final Object the value, null converted to "" value)Protects against adding null values to a map. |
| public static int | |
| public static < the key type K, the value type V> Map | Returns: a synchronized map backed by the given mapthe map to synchronize, must not be null map)Returns a synchronized map backed by the given map. |
| public static < the key type K, the value type V> SortedMap | Returns: a synchronized map backed by the given mapthe map to synchronize, must not be null map)Returns a synchronized sorted map backed by the given sorted map. |
| public static Map | Returns: the hashmap containing the datathe resource bundle to convert, may not be null resourceBundle)Creates a new HashMap using data copied from a ResourceBundle. |
| public static < the key type K, the value type V> Properties | Returns: the properties objectthe map to convert to a Properties object map)Gets a new Properties object initialised with the values from a Map. |
| public static < the key type K, the value type V> IterableMap | Returns: a transformed map backed by the given mapthe map to transform, must not be null, typically empty map, final Transformer<? super K, ? extends K> the transformer for the map keys, null means no transformation keyTransformer, final Transformer<? super V, ? extends V> the transformer for the map values, null means no transformation valueTransformer)Returns a transformed map backed by the given map. |
| public static < the key type K, the value type V> SortedMap | Returns: a transformed map backed by the given mapthe map to transform, must not be null, typically empty map, final Transformer<? super K, ? extends K> the transformer for the map keys, null means no transformation keyTransformer, final Transformer<? super V, ? extends V> the transformer for the map values, null means no transformation valueTransformer)Returns a transformed sorted map backed by the given map. |
| public static < the key type K, the value type V> Map | Returns: an unmodifiable map backed by the given mapthe map to make unmodifiable, must not be null map)Returns an unmodifiable map backed by the given map. |
| public static < the key type K, the value type V> SortedMap | Returns: an unmodifiable map backed by the given mapthe sorted map to make unmodifiable, must not be null map)Returns an unmodifiable sorted map backed by the given sorted map. |
| public static void | verbosePrint(final PrintStream
the stream to print to, must not be null out, final Object The label to be used, may be label, final Map<?, ?> null.
If null, the label is not output.
It typically represents the name of the property in a bean or similar.The map to print, may be map)null.
If null, the text 'null' is output.Prints the given map with nice line breaks. |
| private static void | verbosePrintInternal(final PrintStream
the stream to print to out, final Object the label to be used, may be label, final Map<?, ?> null.
If null, the label is not output.
It typically represents the name of the property in a bean or similar.the map to print, may be map, final Deque<Map<?, ?>> null.
If null, the text 'null' is outputa stack consisting of any maps in which the previous
argument is contained. This is checked to avoid infinite recursion when
printing the output lineage, final boolean flag indicating whether type names should be output. debug)Implementation providing functionality for |