Package org.apache.sshd.common.util
Class MapEntryUtils
java.lang.Object
org.apache.sshd.common.util.MapEntryUtils
Represents an un-modifiable pair of values
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classMapEntryUtils.EnumMapBuilder<K extends Enum<K>,V> static classstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Comparator<Map.Entry<Comparable, ?>> private static final Supplier -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K extends Comparable<K>,V>
Comparator<Map.Entry<K, V>> static <V> Supplier<NavigableMap<String, V>> static <K,V, M extends Map<V, K>>
MflipMap(Map<? extends K, ? extends V> map, Supplier<? extends M> mapCreator, boolean allowDuplicates) Flips between keys and values of an input mapstatic booleanstatic booleanisNotEmpty(Map<?, ?> m) static <K,V, M extends Map<K, V>>
MmapValues(Function<? super V, ? extends K> keyMapper, Supplier<? extends M> mapCreator, Collection<? extends V> values) Creates a map out of a group of valuesstatic <K,V, M extends Map<K, V>>
Mstatic intstatic <T> BinaryOperator<T> static <T,K, U> NavigableMap <K, U> toSortedMap(Iterable<? extends T> values, Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper, Comparator<? super K> comparator) static <T,K, U> Collector <T, ?, NavigableMap<K, U>> toSortedMap(Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper, Comparator<? super K> comparator)
-
Field Details
-
BY_KEY_COMPARATOR
-
CASE_INSENSITIVE_MAP_FACTORY
-
-
Constructor Details
-
MapEntryUtils
private MapEntryUtils()
-
-
Method Details
-
byKeyEntryComparator
- Type Parameters:
K- TheComparablekey typeV- The associated entry value- Returns:
- A
ComparatorforMap.Entry-ies that compares the key values
-
size
-
isEmpty
-
isNotEmpty
-
caseInsensitiveMap
- Type Parameters:
V- Type of mapped value- Returns:
- A
Supplierthat returns a newNavigableMapwhenever itsget()method is invoked
-
flipMap
public static <K,V, M flipMapM extends Map<V, K>> (Map<? extends K, ? extends V> map, Supplier<? extends M> mapCreator, boolean allowDuplicates) Flips between keys and values of an input map- Type Parameters:
K- Original map key typeV- Original map value typeM- Flipped map type- Parameters:
map- The original map to flipmapCreator- The creator of the target mapallowDuplicates- Whether to ignore duplicates on flip- Returns:
- The flipped map result
- Throws:
IllegalArgumentException- if allowDuplicates isfalseand a duplicate value found in the original map.
-
mapValues
@SafeVarargs public static <K,V, M mapValuesM extends Map<K, V>> (Function<? super V, ? extends K> keyMapper, Supplier<? extends M> mapCreator, V... values) -
mapValues
public static <K,V, M mapValuesM extends Map<K, V>> (Function<? super V, ? extends K> keyMapper, Supplier<? extends M> mapCreator, Collection<? extends V> values) Creates a map out of a group of values- Type Parameters:
K- The key typeV- The value typeM- The resultMaptype- Parameters:
keyMapper- TheFunctionthat generates a key for a given value. If the returned key isnullthen the value is not mappedmapCreator- TheSupplierused to create/retrieve the result map - provided non-empty group of valuesvalues- The values to be mapped- Returns:
- The resulting
Map- Note: no validation is made to ensure that 2 (or more) values are not mapped to the same key
-
toSortedMap
public static <T,K, NavigableMap<K,U> U> toSortedMap(Iterable<? extends T> values, Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper, Comparator<? super K> comparator) -
toSortedMap
public static <T,K, Collector<T,U> ?, toSortedMapNavigableMap<K, U>> (Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper, Comparator<? super K> comparator) -
throwingMerger
-