Package org.ametys.core.util
Class MapUtils
- java.lang.Object
-
- org.ametys.core.util.MapUtils
-
-
Field Summary
Fields Modifier and Type Field Description private static BinaryOperator<?>
__DEFAULT_MERGE_FUNCTION
-
Constructor Summary
Constructors Modifier Constructor Description private
MapUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static <V> BinaryOperator<V>
_defaultMergeFunction()
private static <K,V>
Map<K,V>_merge(BinaryOperator<V> mergeFunction, Stream<Map<? extends K,? extends V>> sequentialStreamOfMaps)
static <K,V>
Map<K,V>merge(BinaryOperator<V> mergeFunction, Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2)
Merges the entries of two maps into one map.static <K,V>
Map<K,V>merge(BinaryOperator<V> mergeFunction, Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2, Map<? extends K,? extends V>... others)
Merges the entries of several maps into one map.static <K,V>
Map<K,V>merge(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2)
Merges the entries of two maps into one map.static <K,V>
Map<K,V>merge(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2, Map<? extends K,? extends V>... others)
Merges the entries of several maps into one map.
-
-
-
Field Detail
-
__DEFAULT_MERGE_FUNCTION
private static BinaryOperator<?> __DEFAULT_MERGE_FUNCTION
-
-
Constructor Detail
-
MapUtils
private MapUtils()
-
-
Method Detail
-
_defaultMergeFunction
private static <V> BinaryOperator<V> _defaultMergeFunction()
-
merge
public static <K,V> Map<K,V> merge(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2)
Merges the entries of two maps into one map. Entries of the first one have the priority (i.e. kept if same keys) over ones of the second one.- Type Parameters:
K
- The type of the keysV
- The type of the values- Parameters:
map1
- The first map (not modified)map2
- The second map (not modified)- Returns:
- The merged map
-
merge
@SafeVarargs public static <K,V> Map<K,V> merge(Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2, Map<? extends K,? extends V>... others)
Merges the entries of several maps into one map. Entries of any input map one have the priority (i.e. kept if same keys) over ones of any following map.- Type Parameters:
K
- The type of the keysV
- The type of the values- Parameters:
map1
- The first map (not modified)map2
- The second map (not modified)others
- The other maps (not modified)- Returns:
- The merged map
-
merge
public static <K,V> Map<K,V> merge(BinaryOperator<V> mergeFunction, Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2)
Merges the entries of two maps into one map.- Type Parameters:
K
- The type of the keysV
- The type of the values- Parameters:
mergeFunction
- The merging function, to determine which value of the entry to keep when same keys are encountered.map1
- The first map (not modified)map2
- The second map (not modified)- Returns:
- The merged map
-
merge
@SafeVarargs public static <K,V> Map<K,V> merge(BinaryOperator<V> mergeFunction, Map<? extends K,? extends V> map1, Map<? extends K,? extends V> map2, Map<? extends K,? extends V>... others)
Merges the entries of several maps into one map. Entries of any input map one have the priority (i.e. kept if same keys) over ones of any following map.- Type Parameters:
K
- The type of the keysV
- The type of the values- Parameters:
mergeFunction
- The merging function, to determine which value of the entry to keep when same keys are encountered.map1
- The first map (not modified)map2
- The second map (not modified)others
- The other maps (not modified)- Returns:
- The merged map
-
_merge
private static <K,V> Map<K,V> _merge(BinaryOperator<V> mergeFunction, Stream<Map<? extends K,? extends V>> sequentialStreamOfMaps)
-
-