public class MapUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <K,V> boolean |
equals(Map<K,V> map1,
Map<K,V> map2)
This method allows to check whether or not two maps have the same content
(same keys with same values).
|
static <T> Map<T,T> |
reduceToDirectLinks(Map<T,T> links,
boolean keepIntermediaries)
This method allows to transform a set of chains A-...
|
static <K,V> List<V> |
translate(List<K> keys,
Map<K,V> map,
boolean isMissingKeyAllowed)
While
Map.get(Object) provide the single value assigned to a
single key, this method aims at retrieving a List of values
corresponding to a List of keys. |
public static <T> Map<T,T> reduceToDirectLinks(Map<T,T> links, boolean keepIntermediaries)
Map gives a direct link, like (A, B), (B, D), (C, D), etc. By
aggregating the links we are able to rebuild the chains and find the last
elements of these chains. This method produces a Map in which all
the values correspond to the final element of the chain that the key is
part of.links - the links to reducekeepIntermediaries - true if all the keys should be preserved,
false if only the keys which are not used as
values should be keptIllegalArgumentException - a loop is present at the end of a chain (we cannot have it
elsewhere with a map)public static <K,V> boolean equals(Map<K,V> map1, Map<K,V> map2)
map1 - map2 - true if they are equals, false
otherwisepublic static <K,V> List<V> translate(List<K> keys, Map<K,V> map, boolean isMissingKeyAllowed)
Map.get(Object) provide the single value assigned to a
single key, this method aims at retrieving a List of values
corresponding to a List of keys.keys - the keys to considermap - the translation mapisMissingKeyAllowed - true to map an unknown key to a null
value, false to throw an exceptionIllegalArgumentException - if a requested key is not found in the map and non-mapped
keys are not allowedCopyright © 2014–2015. All rights reserved.