public interface ImmutableMap<K,V> extends java.lang.Iterable<Tuple2<K,V>>, Folds<Tuple2<K,V>>, Filters<Tuple2<K,V>>, Transformable<V>, BiTransformable<K,V>, OnEmpty<Tuple2<K,V>>, PersistentMap<K,V>, OnEmptySwitch<Tuple2<K,V>,ImmutableMap<K,V>>
Modifier and Type | Method and Description |
---|---|
default boolean |
allMatch(java.util.function.Predicate<? super Tuple2<K,V>> c)
True if predicate matches all elements when Monad converted to a Stream
|
<R1,R2> ImmutableMap<R1,R2> |
bimap(java.util.function.BiFunction<? super K,? super V,? extends Tuple2<R1,R2>> map) |
<R1,R2> ImmutableMap<R1,R2> |
bimap(java.util.function.Function<? super K,? extends R1> fn1,
java.util.function.Function<? super V,? extends R2> fn2)
Transform this BiTransformable, changing two value types at once.
|
default ImmutableMap<K,V> |
bipeek(java.util.function.Consumer<? super K> c1,
java.util.function.Consumer<? super V> c2)
Peek at two data types simulatanously (typically to perform a side-effect with each data point)
|
<K2,V2> ImmutableMap<K2,V2> |
concatMap(java.util.function.BiFunction<? super K,? super V,? extends java.lang.Iterable<Tuple2<K2,V2>>> mapper) |
boolean |
contains(Tuple2<K,V> t) |
boolean |
containsKey(K key) |
default boolean |
containsValue(V value) |
ImmutableMap<K,V> |
filter(java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Keep only elements for which the supplied predicates hold
e.g.
|
ImmutableMap<K,V> |
filterKeys(java.util.function.Predicate<? super K> predicate) |
default ImmutableMap<K,V> |
filterNot(java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
ImmutableMap<K,V> |
filterValues(java.util.function.Predicate<? super V> predicate) |
<K2,V2> ImmutableMap<K2,V2> |
flatMap(java.util.function.BiFunction<? super K,? super V,? extends ImmutableMap<K2,V2>> mapper) |
default <K1,K2,R1,R> |
forEach2(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends Tuple2<K2,R>> yieldingFunction) |
default <K1,K2,R1,R> |
forEach2(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,java.lang.Boolean> filterFunction,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends Tuple2<K2,R>> yieldingFunction) |
default <K1,K2,K3,R1,R2,R> |
forEach3(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2,
Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends Tuple2<K3,R>> yieldingFunction) |
default <K1,K2,K3,R1,R2,R> |
forEach3(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2,
Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,java.lang.Boolean> filterFunction,
Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends Tuple2<K3,R>> yieldingFunction) |
default <K1,K2,K3,K4,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2,
Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends java.lang.Iterable<Tuple2<K3,R3>>> iterable3,
Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,? extends Tuple2<K4,R>> yieldingFunction) |
default <K1,K2,K3,K4,R1,R2,R3,R> |
forEach4(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1,
java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2,
Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends java.lang.Iterable<Tuple2<K3,R3>>> iterable3,
Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,java.lang.Boolean> filterFunction,
Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,? extends Tuple2<K4,R>> yieldingFunction) |
Option<V> |
get(K key) |
V |
getOrElse(K key,
V alt) |
V |
getOrElseGet(K key,
java.util.function.Supplier<? extends V> alt) |
default boolean |
isEmpty() |
default java.util.Map<K,V> |
javaMap() |
default ReactiveSeq<K> |
keys() |
<R> ImmutableMap<K,R> |
map(java.util.function.Function<? super V,? extends R> fn)
Transform this functor using the supplied transformation function
|
<R> ImmutableMap<R,V> |
mapKeys(java.util.function.Function<? super K,? extends R> map) |
<R> ImmutableMap<K,R> |
mapValues(java.util.function.Function<? super V,? extends R> map) |
<K2,V2,K3,V3> |
merge(DMap.Two<K2,V2,K3,V3> two) |
<K2,V2> DMap.Two<K,V,K2,V2> |
merge(ImmutableMap<K2,V2> one) |
default java.lang.String |
mkString() |
default ImmutableMap<K,V> |
notNull()
Filter elements retaining only values which are not null
|
default ImmutableMap<K,V> |
onEmpty(Tuple2<K,V> value)
If this Container instance is zero, create a new instance containing the provided value
|
default ImmutableMap<K,V> |
onEmptyGet(java.util.function.Supplier<? extends Tuple2<K,V>> supplier)
If this Container instance is zero, create a new instance containing the value returned from the provided Supplier
|
default ImmutableMap<K,V> |
onEmptySwitch(java.util.function.Supplier<? extends ImmutableMap<K,V>> supplier)
Switch to container created by provided Supplier, if current Container zero
|
default <X extends java.lang.Throwable> |
onEmptyTry(java.util.function.Supplier<? extends X> supplier) |
default ImmutableMap<K,V> |
peek(java.util.function.Consumer<? super V> c)
Peek at the current value of this Transformable, without transforming it
|
ImmutableMap<K,V> |
put(K key,
V value) |
ImmutableMap<K,V> |
put(Tuple2<K,V> keyAndValue) |
ImmutableMap<K,V> |
putAll(PersistentMap<? extends K,? extends V> map) |
ImmutableMap<K,V> |
remove(K key) |
ImmutableMap<K,V> |
removeAll(K... keys) |
default ImmutableMap<K,V> |
removeAllKeys(java.lang.Iterable<? extends K> keys) |
int |
size() |
ReactiveSeq<Tuple2<K,V>> |
stream() |
default <T> LazySeq<T> |
toLazySeq(java.util.function.Function<? super Tuple2<? super K,? super V>,? extends T> fn)
Convert this ImmutableMap to a LazySeq via the provided transformation function
|
default <T> Seq<T> |
toSeq(java.util.function.Function<? super Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a Seq via the provided transformation function
|
default ReactiveSeq<V> |
values() |
anyMatch, atPercentile, bankersQueue, collect, collect, collect, collect, count, countDistinct, doubleStats, elementAt, endsWith, firstValue, foldLeft, foldLeft, foldLeft, foldLeft, foldLeft, foldLeft, foldMap, foldMap, foldMapRight, foldRight, foldRight, foldRight, groupBy, hashSet, headOption, indexOf, indexOfSlice, intStats, iterableTo, join, join, join, lastIndexOf, lastIndexOfSlice, lazySeq, longStats, maxBy, maxBy, maximum, mean, median, minBy, minBy, minimum, mode, noneMatch, nonEmptyList, occurances, populationVariance, print, print, printErr, printOut, scheduleStream, seq, single, single, singleOrElse, startsWith, stdDeviation, sumDouble, sumInt, sumLong, takeOne, toArray, toArray, toCollection, toHashMap, toHashMap, toList, toMap, toMap, toSet, treeSet, variance, vector, withPercentiles, xMatch
equalTo, mapView
default boolean allMatch(java.util.function.Predicate<? super Tuple2<K,V>> c)
Folds
assertThat(ReactiveSeq.of(1,2,3,4,5).allMatch(it-> it>0 && it <6),equalTo(true));
ImmutableMap<K,V> put(K key, V value)
put
in interface PersistentMap<K,V>
ImmutableMap<K,V> put(Tuple2<K,V> keyAndValue)
put
in interface PersistentMap<K,V>
ImmutableMap<K,V> putAll(PersistentMap<? extends K,? extends V> map)
putAll
in interface PersistentMap<K,V>
ImmutableMap<K,V> remove(K key)
remove
in interface PersistentMap<K,V>
ImmutableMap<K,V> removeAll(K... keys)
default ReactiveSeq<K> keys()
default ReactiveSeq<V> values()
default ImmutableMap<K,V> removeAllKeys(java.lang.Iterable<? extends K> keys)
removeAllKeys
in interface PersistentMap<K,V>
default boolean containsValue(V value)
default boolean isEmpty()
isEmpty
in interface PersistentMap<K,V>
boolean containsKey(K key)
containsKey
in interface PersistentMap<K,V>
V getOrElseGet(K key, java.util.function.Supplier<? extends V> alt)
getOrElseGet
in interface PersistentMap<K,V>
int size()
size
in interface PersistentMap<K,V>
default java.lang.String mkString()
<K2,V2> DMap.Two<K,V,K2,V2> merge(ImmutableMap<K2,V2> one)
<K2,V2,K3,V3> DMap.Three<K,V,K2,V2,K3,V3> merge(DMap.Two<K2,V2,K3,V3> two)
ReactiveSeq<Tuple2<K,V>> stream()
<R> ImmutableMap<K,R> mapValues(java.util.function.Function<? super V,? extends R> map)
<R> ImmutableMap<R,V> mapKeys(java.util.function.Function<? super K,? extends R> map)
<R1,R2> ImmutableMap<R1,R2> bimap(java.util.function.BiFunction<? super K,? super V,? extends Tuple2<R1,R2>> map)
<K2,V2> ImmutableMap<K2,V2> flatMap(java.util.function.BiFunction<? super K,? super V,? extends ImmutableMap<K2,V2>> mapper)
<K2,V2> ImmutableMap<K2,V2> concatMap(java.util.function.BiFunction<? super K,? super V,? extends java.lang.Iterable<Tuple2<K2,V2>>> mapper)
ImmutableMap<K,V> filter(java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[3]
ImmutableMap<K,V> filterKeys(java.util.function.Predicate<? super K> predicate)
ImmutableMap<K,V> filterValues(java.util.function.Predicate<? super V> predicate)
default ImmutableMap<K,V> filterNot(java.util.function.Predicate<? super Tuple2<K,V>> predicate)
Filters
of(1,2,3).filter(i->i>2);
//[1,2]
default ImmutableMap<K,V> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
<R> ImmutableMap<K,R> map(java.util.function.Function<? super V,? extends R> fn)
Transformable
of(1,2,3).map(i->i*2)
//[2,4,6]
map
in interface Transformable<V>
fn
- Transformation functiondefault ImmutableMap<K,V> peek(java.util.function.Consumer<? super V> c)
Transformable
of(1,2,3).map(System.out::println)
1
2
3
peek
in interface Transformable<V>
c
- Consumer that recieves each element from this Transformable<R1,R2> ImmutableMap<R1,R2> bimap(java.util.function.Function<? super K,? extends R1> fn1, java.util.function.Function<? super V,? extends R2> fn2)
BiTransformable
MapX<String,Integer> map = MapXs.of("hello",2);
MapX<String,Integer> transformedMap = map.bimap(s->s+" world",i->i*4);
//["hello world",8]
bimap
in interface BiTransformable<K,V>
fn1
- transformation function for the first typefn2
- transformation function for the second typedefault ImmutableMap<K,V> bipeek(java.util.function.Consumer<? super K> c1, java.util.function.Consumer<? super V> c2)
BiTransformable
MapX<String,Integer> map = MapXs.of("hello",2);
map.bipeek(s->System.out.pritnln("key = " + s),System.out::println);
bipeek
in interface BiTransformable<K,V>
c1
- consumer for the first typec2
- consumer for the second typedefault ImmutableMap<K,V> onEmpty(Tuple2<K,V> value)
OnEmpty
default ImmutableMap<K,V> onEmptyGet(java.util.function.Supplier<? extends Tuple2<K,V>> supplier)
OnEmpty
onEmptyGet
in interface OnEmpty<Tuple2<K,V>>
supplier
- to determine new value for containerdefault <X extends java.lang.Throwable> Try<ImmutableMap<K,V>,X> onEmptyTry(java.util.function.Supplier<? extends X> supplier)
default ImmutableMap<K,V> onEmptySwitch(java.util.function.Supplier<? extends ImmutableMap<K,V>> supplier)
OnEmptySwitch
Seq.zero().onEmptySwitch(()->Seq.of(1));
onEmptySwitch
in interface OnEmptySwitch<Tuple2<K,V>,ImmutableMap<K,V>>
supplier
- to create replacement containerdefault <K1,K2,K3,K4,R1,R2,R3,R> ImmutableMap<K4,R> forEach4(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2, Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends java.lang.Iterable<Tuple2<K3,R3>>> iterable3, Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,? extends Tuple2<K4,R>> yieldingFunction)
default <K1,K2,K3,K4,R1,R2,R3,R> ImmutableMap<K4,R> forEach4(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2, Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends java.lang.Iterable<Tuple2<K3,R3>>> iterable3, Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,java.lang.Boolean> filterFunction, Function4<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? super Tuple2<K3,R3>,? extends Tuple2<K4,R>> yieldingFunction)
default <K1,K2,K3,R1,R2,R> ImmutableMap<K3,R> forEach3(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2, Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends Tuple2<K3,R>> yieldingFunction)
default <K1,K2,K3,R1,R2,R> ImmutableMap<K3,R> forEach3(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends java.lang.Iterable<Tuple2<K2,R2>>> iterable2, Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,java.lang.Boolean> filterFunction, Function3<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? super Tuple2<K2,R2>,? extends Tuple2<K3,R>> yieldingFunction)
default <K1,K2,R1,R> ImmutableMap<K2,R> forEach2(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends Tuple2<K2,R>> yieldingFunction)
default <K1,K2,R1,R> ImmutableMap<K2,R> forEach2(java.util.function.Function<? super Tuple2<K,V>,? extends java.lang.Iterable<Tuple2<K1,R1>>> iterable1, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,java.lang.Boolean> filterFunction, java.util.function.BiFunction<? super Tuple2<K,V>,? super Tuple2<K1,R1>,? extends Tuple2<K2,R>> yieldingFunction)
default <T> Seq<T> toSeq(java.util.function.Function<? super Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a single valuedefault <T> LazySeq<T> toLazySeq(java.util.function.Function<? super Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a single value