@GwtCompatible
public class MapExtensions
extends java.lang.Object
maps
.Constructor and Description |
---|
MapExtensions() |
Modifier and Type | Method and Description |
---|---|
static <K,V> java.util.Map<K,V> |
filter(java.util.Map<K,V> original,
Functions.Function2<? super K,? super V,java.lang.Boolean> predicate)
Returns a filtered live view on top of the original map.
|
static <K,V> void |
forEach(java.util.Map<K,V> map,
Procedures.Procedure2<? super K,? super V> procedure)
Applies the given
procedure for each key value pair of the given map . |
static <K,V> void |
forEach(java.util.Map<K,V> map,
Procedures.Procedure3<? super K,? super V,? super java.lang.Integer> procedure)
Applies the given
procedure for each key value pair of the given map . |
static <K,V1,V2> java.util.Map<K,V2> |
mapValues(java.util.Map<K,V1> original,
Functions.Function1<? super V1,? extends V2> transformation)
Returns a map that performs the given
transformation for each value of original when requested. |
public static <K,V> void forEach(java.util.Map<K,V> map, Procedures.Procedure2<? super K,? super V> procedure)
procedure
for each key value pair
of the given map
.map
- the map. May not be null
.procedure
- the procedure. May not be null
.public static <K,V> void forEach(java.util.Map<K,V> map, Procedures.Procedure3<? super K,? super V,? super java.lang.Integer> procedure)
procedure
for each key value pair
of the given map
.
The procedure takes the key, the value and a loop counter. If the counter would overflow, Integer.MAX_VALUE
is returned for all subsequent pairs. The first pair is at index zero.map
- the map. May not be null
.procedure
- the procedure. May not be null
.public static <K,V> java.util.Map<K,V> filter(java.util.Map<K,V> original, Functions.Function2<? super K,? super V,java.lang.Boolean> predicate)
Returns a filtered live view on top of the original map. Changes to one affect the other.
The mapping is done lazily. That is, subsequent access of the values in the map will repeatedly apply the transformation. Characteristics of the original map, such as iteration order, are left intact. Changes in the original map are reflected in the result map. The results supports removal if the original map supports removal.
original
- the original map. May not be null
.predicate
- the predicate. May not be null
.null
.public static <K,V1,V2> java.util.Map<K,V2> mapValues(java.util.Map<K,V1> original, Functions.Function1<? super V1,? extends V2> transformation)
Returns a map that performs the given transformation
for each value of original
when requested.
The mapping is done lazily. That is, subsequent access of the values in the map will repeatedly apply the transformation. Characteristics of the original map, such as iteration order, are left intact. Changes in the original map are reflected in the result map. The results supports removal if the original map supports removal.
original
- the original map. May not be null
.transformation
- the transformation. May not be null
.null
.