Package org.elasticsearch.common.util
Class Maps
java.lang.Object
org.elasticsearch.common.util.Maps
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K, V> Map<K,V>
copyMapWithRemovedEntry(Map<K,V> map, K key)
Remove the specified key from the provided immutable map by copying the underlying map and filtering out the specified key if that key exists.static <K, V> boolean
deepEquals(Map<K,V> left, Map<K,V> right)
Returnstrue
if the two specified maps are equal to one another.Returns an array where all internal maps and optionally arrays are flattened into the root map.
-
Constructor Details
-
Maps
public Maps()
-
-
Method Details
-
deepEquals
Returnstrue
if the two specified maps are equal to one another. Two maps are considered equal if both represent identical mappings where values are checked with Objects.deepEquals. The primary use case is to check if two maps with array values are equal.- Parameters:
left
- one map to be tested for equalityright
- the other map to be tested for equality- Returns:
true
if the two maps are equal
-
copyMapWithRemovedEntry
Remove the specified key from the provided immutable map by copying the underlying map and filtering out the specified key if that key exists.- Type Parameters:
K
- the type of the keys in the mapV
- the type of the values in the map- Parameters:
map
- the immutable map to remove the key fromkey
- the key to be removed- Returns:
- an immutable map that contains the items from the specified map with the provided key removed
-
flatten
public static Map<String,Object> flatten(Map<String,Object> map, boolean flattenArrays, boolean ordered)Returns an array where all internal maps and optionally arrays are flattened into the root map. For example the map {"foo": {"bar": 1, "baz": [2, 3]}} will become {"foo.bar": 1, "foo.baz.0": 2, "foo.baz.1": 3}. Note that if maps contains keys with "." or numbers it is possible that such keys will be silently overridden. For example the map {"foo": {"bar": 1}, "foo.bar": 2} will become {"foo.bar": 1} or {"foo.bar": 2}.- Parameters:
map
- - input to be flattenedflattenArrays
- - if false, arrays will be ignoredordered
- - if true the resulted map will be sorted- Returns:
-