Package org.apache.camel.util
Class CollectionHelper
java.lang.Object
org.apache.camel.util.CollectionHelper
A number of helper methods for working with collections
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
Sets the value of the entry in the map for the given key, though if the map already contains a value for the given key then the value is appended to a list of values.static String
static <T> Set<T>
createSetContaining
(T... contents) flattenKeysInMap
(Map<String, Object> map, String separator) Traverses the given map recursively and flattern the keys by combining them with the optional separator.static <K,
V> Map<K, V> immutableMapOf
(Supplier<Map<K, V>> creator, K key, V value, Object... keyVals) Build an immutable map from varargs.static <K,
V> Map<K, V> immutableMapOf
(K key, V value, Object... keyVals) Build an immutable map from varargs.static <K,
V> Map<K, V> Build a map from varargs.static <K,
V> Map<K, V> Build a map from varargs.static <K,
V> Map<K, V> Build a new map that is the result of merging the given list of maps.static Properties
propertiesOf
(String key, String value, String... keyVals) Build aProperties
from varargs.static Integer
Returns the size of the collection if it can be determined to be a collectionstatic <K,
V> Map<K, V> unmodifiableMap
(Map<K, V> map) Build an unmodifiable map on top of a given map.
-
Method Details
-
size
Returns the size of the collection if it can be determined to be a collection- Parameters:
value
- the collection- Returns:
- the size, or null if not a collection
-
appendValue
Sets the value of the entry in the map for the given key, though if the map already contains a value for the given key then the value is appended to a list of values.- Parameters:
map
- the map to add the entry tokey
- the key in the mapvalue
- the value to put in the map
-
createSetContaining
-
collectionAsCommaDelimitedString
-
flattenKeysInMap
Traverses the given map recursively and flattern the keys by combining them with the optional separator.- Parameters:
map
- the mapseparator
- optional separator to use in key name, for example a hyphen or dot.- Returns:
- the map with flattern keys
-
unmodifiableMap
Build an unmodifiable map on top of a given map. Note tha thew given map is copied if not null.- Parameters:
map
- a map- Returns:
- an unmodifiable map.
-
mapOf
Build a map from varargs. -
immutableMapOf
public static <K,V> Map<K,V> immutableMapOf(Supplier<Map<K, V>> creator, K key, V value, Object... keyVals) Build an immutable map from varargs. -
mapOf
Build a map from varargs. -
immutableMapOf
Build an immutable map from varargs. -
propertiesOf
Build aProperties
from varargs. -
mergeMaps
Build a new map that is the result of merging the given list of maps.
-