public class ImmutableMaps extends Object
| Modifier and Type | Method and Description |
|---|---|
static <K1,K2,V1,V2> |
collect(Map<K1,V1> from,
Function<? super K1,Option<K2>> keyPartial,
Function<? super V1,Option<V2>> valuePartial)
Filters and maps (aka transforms) the source map.
|
static <K1,K2,V1,V2> |
collect(Map<K1,V1> from,
Function<Map.Entry<K1,V1>,Option<Map.Entry<K2,V2>>> partial)
Filters and maps (aka transforms) the source map.
|
static <K1,K2,V> com.google.common.collect.ImmutableMap<K2,V> |
collectByKey(Map<K1,V> from,
Function<? super K1,Option<K2>> keyPartial)
Filters and maps (aka transforms) the source map.
|
static <K,V1,V2> com.google.common.collect.ImmutableMap<K,V2> |
collectByValue(Map<K,V1> from,
Function<? super V1,Option<V2>> valuePartial)
Filters and maps (aka transforms) the source map.
|
static <K,V> com.google.common.collect.ImmutableMap<K,V> |
mapBy(Iterable<V> from,
Function<? super V,? extends K> keyTransformer)
Builds an immutable map that is keyed by the result of applying
keyTransformer to each element of the given iterable of values.
|
static <K,V> BiFunction<K,V,Map.Entry<K,V>> |
mapEntry()
Returns a function that takes a key of type K and a value of type V and
returns a Map entry.
|
static <K,V> com.google.common.collect.ImmutableMap<K,V> |
mapTo(Iterable<K> from,
Function<? super K,? extends V> valueTransformer)
Builds an immutable map from the given iterable and compute the value by
applying the valueTransformer.
|
static <K,V> com.google.common.collect.ImmutableMap<K,V> |
toMap(Iterable<Map.Entry<K,V>> from)
Builds an immutable map from the given iterable of
Map.Entry. |
static <T,K,V> com.google.common.collect.ImmutableMap<K,V> |
toMap(Iterable<T> from,
Function<? super T,? extends K> keyTransformer,
Function<? super T,? extends V> valueTransformer)
Builds an immutable map from the given iterable, with key derived from the
application of the iterable to the keyTransformer, and value derived from
the application of the iterable to the valueTransformer.
|
static <K1,K2,V1,V2> |
transform(Map<K1,V1> from,
Function<? super K1,? extends K2> keyTransformer,
Function<? super V1,? extends V2> valueTransformer)
Returns an immutable map that applies the keyTransformer and
valueTransformer functions to each entry of
fromMap. |
static <K1,K2,V1,V2> |
transform(Map<K1,V1> from,
Function<Map.Entry<K1,V1>,Map.Entry<K2,V2>> function)
Returns an immutable map that applies function to each entry of
fromMap. |
static <K1,K2,V> com.google.common.collect.ImmutableMap<K2,V> |
transformKey(Map<K1,V> from,
Function<? super K1,? extends K2> keyTransformer)
Returns an immutable map that applies keyTransformer to the key of each
entry of the source map.
|
static <K,V1,V2> com.google.common.collect.ImmutableMap<K,V2> |
transformValue(Map<K,V1> from,
Function<? super V1,? extends V2> valueTransformer)
Returns an immutable map that applies valueTransformer to the value of each
entry of the source map.
|
public static <K,V> BiFunction<K,V,Map.Entry<K,V>> mapEntry()
K - the key typeV - the value typepublic static <K,V> com.google.common.collect.ImmutableMap<K,V> toMap(Iterable<Map.Entry<K,V>> from)
Map.Entry.
Any null entries will be filtered out. Additionally, any
entries containing null key or value will also be filtered
out. If multiple entries return the same key,
IllegalArgumentException will be thrown.
K - the key typeV - the value typefrom - the iterable we use as the sourcepublic static <T,K,V> com.google.common.collect.ImmutableMap<K,V> toMap(Iterable<T> from, Function<? super T,? extends K> keyTransformer, Function<? super T,? extends V> valueTransformer)
null value is allowed and will be passed to the keyTransformer
and valueTransformer. However, if either the keyTransformer or the
valueTransformer returns null for an entry, the entry is
ignored. If keyTransformer returns the same key for multiple entries,
IllegalArgumentException will be thrown.
T - the input typeK - the key typeV - the value typefrom - the iterable we use as the sourcekeyTransformer - transform keysvalueTransformer - transform valuespublic static <K,V> com.google.common.collect.ImmutableMap<K,V> mapBy(Iterable<V> from, Function<? super V,? extends K> keyTransformer)
null value is allowed but will be ignored. If keyTransformer
returns the same key for multiple entries,
IllegalArgumentException will be thrown.
K - the key typeV - the value typefrom - the iterable we use as the sourcekeyTransformer - transform keyspublic static <K,V> com.google.common.collect.ImmutableMap<K,V> mapTo(Iterable<K> from, Function<? super K,? extends V> valueTransformer)
null value is allowed but will be ignored. If there are
duplicate entries in the iterable,
IllegalArgumentException will be thrown.
K - the key typeV - the value typefrom - the iterable we use as the sourcevalueTransformer - transform valuespublic static <K1,K2,V1,V2> com.google.common.collect.ImmutableMap<K2,V2> transform(Map<K1,V1> from, Function<Map.Entry<K1,V1>,Map.Entry<K2,V2>> function)
fromMap. If null is returned by the function for any
entry, or if an entry returned by the function contains a null
key or value, that entry is discarded in the result. If the function
returns entries with the same key for multiple entries,
IllegalArgumentException will be thrown.K1 - the input key typeK2 - the output key typeV1 - the input value typeV2 - the output value typefrom - the map we use as the sourcefunction - transform keys and valuespublic static <K1,K2,V1,V2> com.google.common.collect.ImmutableMap<K2,V2> transform(Map<K1,V1> from, Function<? super K1,? extends K2> keyTransformer, Function<? super V1,? extends V2> valueTransformer)
fromMap. If for any
entry, a null key or value is returned, that entry is
discarded in the result. If the keyTransformer function returns the same
key for multiple entries, IllegalArgumentException will
be thrown.K1 - the input key typeK2 - the output key typeV1 - the input value typeV2 - the output value typefrom - the map we use as the sourcekeyTransformer - transform keysvalueTransformer - transform valuespublic static <K1,K2,V> com.google.common.collect.ImmutableMap<K2,V> transformKey(Map<K1,V> from, Function<? super K1,? extends K2> keyTransformer)
null is returned by the
keyTransformer for any entry, that entry is discarded in the result. If an
entry contains a null value, it will also be discarded in the
result. If the function returns the same result key for multiple
keys, IllegalArgumentException will be thrown.K1 - the input key typeK2 - the output key typeV - the value typefrom - the map we use as the sourcekeyTransformer - transform keyspublic static <K,V1,V2> com.google.common.collect.ImmutableMap<K,V2> transformValue(Map<K,V1> from, Function<? super V1,? extends V2> valueTransformer)
null is returned by the
valueTransformer for any entry, that entry is discarded in the result. If
an entry contains a null key, it will also be discarded in the
result.K - the key typeV1 - the input value typeV2 - the output value typefrom - the iterable we use as the sourcevalueTransformer - transform valuespublic static <K1,K2,V1,V2> com.google.common.collect.ImmutableMap<K2,V2> collect(Map<K1,V1> from, Function<Map.Entry<K1,V1>,Option<Map.Entry<K2,V2>>> partial)
K1 - the input key typeK2 - the output key typeV1 - the input value typeV2 - the output value typefrom - the iterable we use as the sourcepartial - transform and select entriespublic static <K1,K2,V1,V2> com.google.common.collect.ImmutableMap<K2,V2> collect(Map<K1,V1> from, Function<? super K1,Option<K2>> keyPartial, Function<? super V1,Option<V2>> valuePartial)
K1 - the input key typeK2 - the output key typeV1 - the input value typeV2 - the output value typefrom - the iterable we use as the sourcekeyPartial - transform and collect keysvaluePartial - transform and collect valuespublic static <K1,K2,V> com.google.common.collect.ImmutableMap<K2,V> collectByKey(Map<K1,V> from, Function<? super K1,Option<K2>> keyPartial)
K1 - the input key typeK2 - the output key typeV - the value typefrom - the iterable we use as the sourcekeyPartial - transform and collect keyspublic static <K,V1,V2> com.google.common.collect.ImmutableMap<K,V2> collectByValue(Map<K,V1> from, Function<? super V1,Option<V2>> valuePartial)
K - the key typeV1 - the input value typeV2 - the output value typefrom - the iterable we use as the sourcevaluePartial - transform and collect valuesCopyright © 2018 Atlassian. All rights reserved.