public final class MapExtensions
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static <K,V> K |
getKeyFromValue(java.util.Map<K,V> map,
V value)
Returns the first founded key from the given value or null if nothing is found.
|
static <K,V> java.util.Collection<K> |
getKeysFromValue(java.util.Map<K,V> map,
V value)
Returns a Collection from all founded keys from the given value or null if nothing found.
|
static <K> java.util.Map<K,java.lang.Integer> |
mergeAndSummarize(java.util.Map<K,java.lang.Integer> valueCounterMap,
java.util.Map<K,java.lang.Integer> summarizeWithThisValueCounterMap)
Factory method for create a map for counting elements of the given collection
|
static <K> java.util.Map<K,java.lang.Integer> |
mergeAndSummarize(java.util.Map<K,java.lang.Integer> valueCounterMap,
java.util.Map<K,java.lang.Integer> summarizeWithThisValueCounterMap,
boolean fullMerge)
Factory method for create a map for counting elements of the given collection
|
static <K,V extends java.lang.Comparable<? super V>> |
sortByValue(java.util.Map<K,V> map,
boolean reversed)
Sort the given Map by its values and returns a sorted list by the values of the given Map
|
static <K,V extends java.lang.Comparable<? super V>> |
sortByValue(java.util.Map<K,V> map,
java.util.Comparator<? super V> comparator)
Sort the given Map by its values and returns a sorted list by the values of the given Map
|
static <K,V extends java.lang.Comparable<? super V>> |
sortByValueAsList(java.util.Map<K,V> map,
boolean reversed)
Sort the given Map by its values and returns a sorted list by the values of the given Map
|
static <K,V extends java.lang.Comparable<? super V>> |
sortByValueAsList(java.util.Map<K,V> map,
java.util.Comparator<? super V> comparator)
Sort the given Map by its values and returns a sorted list by the values of the given Map
|
static <T> java.util.Map<T,T> |
toGenericMap(T[][] twoDimArray)
Converts a two dimensional Array to a Map.
|
static java.util.Map<java.lang.String,java.lang.String> |
toMap(java.lang.String[][] twoDimArray)
Converts a two dimensional String Array to a Map.
|
public static <K,V> K getKeyFromValue(java.util.Map<K,V> map,
V value)
K - the generic type of the keyV - the generic type of the valuemap - The Map.value - The value.public static <K,V> java.util.Collection<K> getKeysFromValue(java.util.Map<K,V> map,
V value)
K - the generic type of the keyV - the generic type of the valuemap - The Map.value - The value.public static <K> java.util.Map<K,java.lang.Integer> mergeAndSummarize(java.util.Map<K,java.lang.Integer> valueCounterMap,
java.util.Map<K,java.lang.Integer> summarizeWithThisValueCounterMap)
K - the generic type of the elementsvalueCounterMap - the counter mapsummarizeWithThisValueCounterMap - the other counter map that will be summarized with the first mappublic static <K> java.util.Map<K,java.lang.Integer> mergeAndSummarize(java.util.Map<K,java.lang.Integer> valueCounterMap,
java.util.Map<K,java.lang.Integer> summarizeWithThisValueCounterMap,
boolean fullMerge)
K - the generic type of the elementsvalueCounterMap - the counter mapsummarizeWithThisValueCounterMap - the other counter map that will be summarized with the first mapfullMerge - if true all keys from both maps will be considered by the merge otherwise only the
keys of the first map will be consideredpublic static <K,V extends java.lang.Comparable<? super V>> java.util.Map<K,V> sortByValue(java.util.Map<K,V> map,
boolean reversed)
K - the generic type of the keyV - the generic type of the valuemap - the Map to sortreversed - the flag if the result should be in reversed orderpublic static <K,V extends java.lang.Comparable<? super V>> java.util.Map<K,V> sortByValue(java.util.Map<K,V> map,
java.util.Comparator<? super V> comparator)
K - the generic type of the keyV - the generic type of the valuemap - the Map to sortcomparator - the comparator to sortpublic static <K,V extends java.lang.Comparable<? super V>> java.util.List<java.util.Map.Entry<K,V>> sortByValueAsList(java.util.Map<K,V> map,
boolean reversed)
K - the generic type of the keyV - the generic type of the valuemap - The Map to sortreversed - the flag if the result should be in reversed orderpublic static <K,V extends java.lang.Comparable<? super V>> java.util.List<java.util.Map.Entry<K,V>> sortByValueAsList(java.util.Map<K,V> map,
java.util.Comparator<? super V> comparator)
K - the generic type of the keyV - the generic type of the valuemap - The Map to sortcomparator - the comparator to sortpublic static <T> java.util.Map<T,T> toGenericMap(T[][] twoDimArray)
T - the generic typetwoDimArray - The two dimensional Array.public static java.util.Map<java.lang.String,java.lang.String> toMap(java.lang.String[][] twoDimArray)
twoDimArray - The two dimensional String Array.