public final class CollectionHelper extends Object
Modifier and Type | Method and Description |
---|---|
static void |
appendValue(Map<String,Object> map,
String key,
Object value)
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 |
collectionAsCommaDelimitedString(Collection<?> col) |
static String |
collectionAsCommaDelimitedString(String[] col) |
static <T> Set<T> |
createSetContaining(T... contents) |
static Map<String,Object> |
flatternKeysInMap(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(K key,
V value,
Object... keyVals)
Build an immutable map from varargs.
|
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> |
mapOf(K key,
V value,
Object... keyVals)
Build a map from varargs.
|
static <K,V> Map<K,V> |
mapOf(Supplier<Map<K,V>> creator,
K key,
V value,
Object... keyVals)
Build a map from varargs.
|
static Integer |
size(Object value)
Returns the size of the collection if it can be determined to be a collection
|
static <K,V> Map<K,V> |
unmodifiableMap(Map<K,V> map)
Build an unmodifiable map on top of a given map.
|
public static Integer size(Object value)
value
- the collectionpublic static void appendValue(Map<String,Object> map, String key, Object value)
map
- the map to add the entry tokey
- the key in the mapvalue
- the value to put in the mappublic static <T> Set<T> createSetContaining(T... contents)
public static String collectionAsCommaDelimitedString(String[] col)
public static String collectionAsCommaDelimitedString(Collection<?> col)
public static Map<String,Object> flatternKeysInMap(Map<String,Object> map, String separator)
map
- the mapseparator
- optional separator to use in key name, for example a hyphen or dot.public static <K,V> Map<K,V> unmodifiableMap(Map<K,V> map)
map
- a mappublic static <K,V> Map<K,V> mapOf(Supplier<Map<K,V>> creator, K key, V value, Object... keyVals)
public static <K,V> Map<K,V> immutableMapOf(Supplier<Map<K,V>> creator, K key, V value, Object... keyVals)
public static <K,V> Map<K,V> mapOf(K key, V value, Object... keyVals)
public static <K,V> Map<K,V> immutableMapOf(K key, V value, Object... keyVals)
Apache Camel