Package com.itextpdf.commons.utils
Class MapUtil
- java.lang.Object
-
- com.itextpdf.commons.utils.MapUtil
-
public final class MapUtil extends java.lang.ObjectUtility class for work with collections. Not for public use.
-
-
Field Summary
Fields Modifier and Type Field Description private static intHASH_MULTIPLIER
-
Constructor Summary
Constructors Modifier Constructor Description privateMapUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <K,V>
booleanequals(java.util.Map<K,V> m1, java.util.Map<K,V> m2)Checks if twomapsare equal: the are of the same types and has equal number of stored entries and both has the same set of keys ans each key is associated with an appropriate value.static <K,V>
intgetHashCode(java.util.Map<K,V> m1)Calculates the hash code of themap.static <K,V>
voidmerge(java.util.Map<K,V> destination, java.util.Map<K,V> source, java.util.function.BiFunction<V,V,V> valuesMerger)Merges data from source Map into destination Map using provided function if key exists in both Maps.static <K,V>
voidputIfNotNull(java.util.Map<K,V> map, K key, V value)Puts value to map if the value is not null.
-
-
-
Field Detail
-
HASH_MULTIPLIER
private static final int HASH_MULTIPLIER
- See Also:
- Constant Field Values
-
-
Method Detail
-
equals
public static <K,V> boolean equals(java.util.Map<K,V> m1, java.util.Map<K,V> m2)Checks if twomapsare equal: the are of the same types and has equal number of stored entries and both has the same set of keys ans each key is associated with an appropriate value.- Type Parameters:
K- is a type of keysV- is a type of values- Parameters:
m1- is the first mapm2- is the second map- Returns:
trueif maps are equal andfalseotherwise
-
merge
public static <K,V> void merge(java.util.Map<K,V> destination, java.util.Map<K,V> source, java.util.function.BiFunction<V,V,V> valuesMerger)Merges data from source Map into destination Map using provided function if key exists in both Maps. If key doesn't exist in destination Map in will be putted directly.- Type Parameters:
K- is a type of keysV- is a type of values- Parameters:
destination- Map to which data will be merged.source- Map from which data will be taken.valuesMerger- function which will be used to merge Maps values.
-
getHashCode
public static <K,V> int getHashCode(java.util.Map<K,V> m1)
Calculates the hash code of themap.- Type Parameters:
K- is a type of keysV- is a type of values- Parameters:
m1- is the map- Returns:
- the hash code of the
map.
-
putIfNotNull
public static <K,V> void putIfNotNull(java.util.Map<K,V> map, K key, V value)Puts value to map if the value is not null.- Type Parameters:
K- is a type of keyV- is a type of value- Parameters:
map- the map in which value can be pushedkey- the keyvalue- the value
-
-