Class MapUtil
java.lang.Object
com.itextpdf.commons.utils.MapUtil
Utility class for work with collections. Not for public use.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> boolean 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> int getHashCode(Map<K, V> m1) Calculates the hash code of themap.static <K,V> void merge(Map<K, V> destination, Map<K, V> source, 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> void putIfNotNull(Map<K, V> map, K key, V value) Puts value to map if the value is not null.
-
Field Details
-
HASH_MULTIPLIER
private static final int HASH_MULTIPLIER- See Also:
-
-
Constructor Details
-
MapUtil
private MapUtil()
-
-
Method Details
-
equals
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(Map<K, V> destination, Map<K, V> source, 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
-
putIfNotNull
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
-