Package net.sf.jstuff.core.collection
Class Maps
java.lang.Object
net.sf.jstuff.core.collection.Maps
- Author:
- Sebastian Thomschke
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> Maps.MapDiff<K, V> static <K,
V> Maps.MapDiff<K, V> static <K,
V> V static <K,
V> V getOrThrow
(Map<K, V> map, K key) static <K,
V> ArrayList<K> keysAsArrayList
(Map<K, V> map) static <K,
V> CharSequence map2string
(Map<K, V> values, String valueSeparator, String assignmentOperator) Returns string in the format of "name1=value1,name2=value2" (if valueSeparator="," and assignmentOperator="=") Opposite totoMap(String, String, String)
static <K,
V> HashMap<K, V> static <K,
V> HashMap<K, V> newHashMap
(int initialSize) static <K,
V> HashMap<K, V> newHashMap
(@Nullable Map<? extends K, ? extends V> initialValues) static <K,
V> HashMap<K, V> newHashMap
(Object @Nullable [] initialKeysAndValues) static <K,
V, KK extends K, VV extends V>
HashMap<K,V> newHashMap
(KK firstKey, VV firstValue, Object... moreInitialKeysAndValues) static <K,
V> LinkedHashMap<K, V> static <K,
V> LinkedHashMap<K, V> newLinkedHashMap
(int initialSize) static <K,
V> LinkedHashMap<K, V> newLinkedHashMap
(Object @Nullable [] initialKeysAndValues) static <K,
V, KK extends K, VV extends V>
LinkedHashMap<K,V> newLinkedHashMap
(KK firstKey, VV firstValue, Object... moreInitialKeysAndValues) static <K,
V> ThreadLocal<HashMap<K, V>> static <K,
V> ThreadLocal<WeakHashMap<K, V>> static <K,
V> TreeMap<K, V> static <K,
V> TreeMap<K, V> newTreeMap
(Comparator<? super K> keyComparator) static <K,
V> TreeMap<K, V> newTreeMap
(Comparator<? super K> keyComparator, Object @Nullable [] initialKeysAndValues) static <K,
V, KK extends K, VV extends V>
TreeMap<K,V> newTreeMap
(Comparator<? super K> keyComparator, KK firstKey, VV firstValue, Object... moreInitialKeysAndValues) static <K,
V, KK extends K, VV extends V>
TreeMap<K,V> newTreeMap
(KK firstKey, VV firstValue, Object... moreInitialKeysAndValues) static <K,
V, M extends Map<K, V>>
Mstatic <K,
V, M extends Map<K, V>>
MputAll
(M map, K[] keys, V[] values) static <K,
V, KK extends K, VV extends V, M extends Map<K, V>>
Mstatic <K,
V> Map<K, V> putAllIfAbsent
(Map<K, V> map, Map<? extends K, ? extends V> entriesToAdd) static <K,
V, M extends Map<K, V>>
MputAllIfAbsent
(M map, Object @Nullable [] keysAndValues) static <K,
V, M extends Map<K, V>>
MputAllIfAbsent
(M map, K[] keys, V[] values) static <K,
V, KK extends K, VV extends V, M extends Map<K, V>>
MputAllIfAbsent
(M map, KK firstKey, VV firstValue, Object... moreKeysAndValues) static <KK,
V> Map<KK, V> static <KK,
V, VV> Map<KK, VV> static <K,
KK, V> Map<KK, V> remap
(Map<K, V> map, BiFunction<K, V, KK> keyMapper) static <K,
KK, V, VV>
Map<KK,VV> remap
(Map<K, V> map, BiFunction<K, V, KK> keyMapper, BiFunction<K, V, VV> valueMapper) static <K,
V extends Comparable<V>>
@NonNull Map<K,V> sortByValue
(@NonNull Map<K, V> map) static <K,
V extends Comparable<V>>
@NonNull Map<K,V> sortByValue
(@NonNull Map<K, V> map, @NonNull SortDirection direction) static <K,
V> Map<K, V> sortByValue
(Map<K, V> map, Comparator<V> comparator) Converts key/value pairs defined in a string into a map.static <T> Map<T,
T> toMap
(T... keysAndValues)
-
Constructor Details
-
Maps
public Maps()
-
-
Method Details
-
diff
-
diff
public static <K,V> Maps.MapDiff<K,V> diff(Map<K, V> leftMap, Map<K, V> rightMap, IsEqual<? super V> isEqual) -
get
-
getOrThrow
- Throws:
NoSuchElementException
-
keysAsArrayList
-
map2string
public static <K,V> CharSequence map2string(Map<K, V> values, String valueSeparator, String assignmentOperator) Returns string in the format of "name1=value1,name2=value2" (if valueSeparator="," and assignmentOperator="=") Opposite totoMap(String, String, String)
-
newHashMap
-
newHashMap
-
newHashMap
-
newHashMap
-
newHashMap
-
newLinkedHashMap
-
newLinkedHashMap
-
newLinkedHashMap
public static <K,V, LinkedHashMap<K,KK extends K, VV extends V> V> newLinkedHashMap(KK firstKey, VV firstValue, Object... moreInitialKeysAndValues) -
newLinkedHashMap
-
newThreadLocalHashMap
-
newThreadLocalWeakHashMap
-
newTreeMap
-
newTreeMap
-
newTreeMap
public static <K,V, TreeMap<K,KK extends K, VV extends V> V> newTreeMap(Comparator<? super K> keyComparator, KK firstKey, VV firstValue, Object... moreInitialKeysAndValues) -
newTreeMap
public static <K,V> TreeMap<K,V> newTreeMap(Comparator<? super K> keyComparator, Object @Nullable [] initialKeysAndValues) -
newTreeMap
-
putAll
-
putAll
-
putAll
-
putAllIfAbsent
-
putAllIfAbsent
-
putAllIfAbsent
-
putAllIfAbsent
-
remap
-
remap
-
remap
-
remap
public static <K,KK, Map<KK,V, VV> VV> remap(Map<K, V> map, BiFunction<K, V, KK> keyMapper, BiFunction<K, V, VV> valueMapper) -
sortByValue
@NonNullByDefault({}) public static <K,V extends Comparable<V>> @NonNull Map<K,V> sortByValue(@NonNull Map<K, V> map) -
sortByValue
-
sortByValue
@NonNullByDefault({}) public static <K,V extends Comparable<V>> @NonNull Map<K,V> sortByValue(@NonNull Map<K, V> map, @NonNull SortDirection direction) -
toMap
public static Map<String,String> toMap(String valuePairs, String valueSeparator, String assignmentOperator) Converts key/value pairs defined in a string into a map. E.g. toMap("name1=value1,name2=value2", "\"", "=") -
toMap
-