K
- Key typeV
- Value typepublic interface MapX<K,V> extends To<MapX<K,V>>, java.util.Map<K,V>, Unwrapable, FluentMapX<K,V>, BiTransformable<K,V>, Transformable<V>, IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>, OnEmpty<org.jooq.lambda.tuple.Tuple2<K,V>>, OnEmptySwitch<org.jooq.lambda.tuple.Tuple2<K,V>,java.util.Map<K,V>>, org.reactivestreams.Publisher<org.jooq.lambda.tuple.Tuple2<K,V>>, Folds<org.jooq.lambda.tuple.Tuple2<K,V>>, CyclopsCollectable<org.jooq.lambda.tuple.Tuple2<K,V>>
Modifier and Type | Method and Description |
---|---|
default boolean |
allMatch(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> c)
True if predicate matches all elements when Monad converted to a Stream
|
default boolean |
anyMatch(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> c)
True if a singleUnsafe element matches when Monad converted to a Stream
|
default <U1,U2> MapX<U1,U2> |
bicast(java.lang.Class<U1> type1,
java.lang.Class<U2> type2)
Cast two data types simulatanously.
|
default <R1,R2> MapX<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 MapX<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)
|
default <R1,R2> MapX<R1,R2> |
bitrampoline(java.util.function.Function<? super K,? extends Trampoline<? extends R1>> mapper1,
java.util.function.Function<? super V,? extends Trampoline<? extends R2>> mapper2)
Perform a tail-call optimized recursive transformation operation across two data points simultaneously
|
default <U> MapX<K,U> |
cast(java.lang.Class<? extends U> type)
Cast all elements in a reactiveStream to a given type, possibly throwing a
ClassCastException . |
static <K,V> java.util.stream.Collector<org.jooq.lambda.tuple.Tuple2<? extends K,? extends V>,?,java.util.Map<K,V>> |
defaultCollector() |
static <K,V> MapX<K,V> |
empty() |
default MapX<K,V> |
filter(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> fn)
Keep only elements for which the supplied predicates hold
e.g.
|
default MapX<K,V> |
filterNot(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> fn)
Remove any elements for which the predicate holds (inverse operation to filter)
e.g.
|
default <KR,VR> MapX<KR,VR> |
flatMap(java.util.function.BiFunction<? super K,? super V,? extends MapX<KR,VR>> fn) |
static <K,V> MapX<K,V> |
fromMap(java.util.stream.Collector<org.jooq.lambda.tuple.Tuple2<? extends K,? extends V>,?,java.util.Map<K,V>> collector,
java.util.Map<? extends K,? extends V> map)
Wrap a map in a MapX, also supplying a Collector for use in operations
|
static <K,V> MapX<K,V> |
fromMap(java.util.Map<? extends K,? extends V> map)
Wrap a Map in a MapX
|
default MapX<K,V> |
fromStream(ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,V>> stream)
Construct a new MapX with the same collector from the supplied Stream
|
<K,V> java.util.stream.Collector<org.jooq.lambda.tuple.Tuple2<? extends K,? extends V>,?,java.util.Map<K,V>> |
getCollector() |
static <K,V> java.util.stream.Collector<org.jooq.lambda.tuple.Tuple2<? extends K,? extends V>,?,java.util.Map<K,V>> |
immutableCollector() |
boolean |
isEmpty() |
default java.util.Iterator<org.jooq.lambda.tuple.Tuple2<K,V>> |
iterator() |
default <R> MapX<K,R> |
map(java.util.function.Function<? super V,? extends R> fn)
Transform this functor using the supplied transformation function
|
default java.util.Optional<org.jooq.lambda.tuple.Tuple2<K,V>> |
max(java.util.Comparator<? super org.jooq.lambda.tuple.Tuple2<K,V>> comparator)
Get the maximum value by a function.
|
default java.util.Optional<org.jooq.lambda.tuple.Tuple2<K,V>> |
min(java.util.Comparator<? super org.jooq.lambda.tuple.Tuple2<K,V>> comparator)
Get the minimum value by a function.
|
default MapX<K,V> |
minus(java.lang.Object key) |
default MapX<K,V> |
minusAll(java.util.Collection<?> keys) |
default boolean |
noneMatch(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> c) |
default MapX<K,V> |
notNull()
Filter elements retaining only values which are not null
|
default MapX<K,V> |
onEmpty(org.jooq.lambda.tuple.Tuple2<K,V> value)
If this Container instance is zero, create a new instance containing the provided value
|
default MapX<K,V> |
onEmptyGet(java.util.function.Supplier<? extends org.jooq.lambda.tuple.Tuple2<K,V>> supplier)
If this Container instance is zero, create a new instance containing the value returned from the provided Supplier
|
default MapX<K,V> |
onEmptySwitch(java.util.function.Supplier<? extends java.util.Map<K,V>> supplier)
Switch to container created by provided Supplier, if current Container zero
|
default <X extends java.lang.Throwable> |
onEmptyThrow(java.util.function.Supplier<? extends X> supplier)
If this container instance is zero, throw the exception returned by the provided Supplier
|
default MapX<K,V> |
peek(java.util.function.Consumer<? super V> c)
Peek at the current value of this Transformable, without transforming it
|
default MapX<K,V> |
plus(K key,
V value) |
default MapX<K,V> |
plusAll(java.util.Map<? extends K,? extends V> map) |
default MapX<K,V> |
removeAll(org.jooq.lambda.tuple.Tuple2<K,V>... values)
Remove all supplied elements from this filterable
|
default MapX<K,V> |
removeAllI(java.lang.Iterable<? extends org.jooq.lambda.tuple.Tuple2<K,V>> it)
Remove all elements in the supplied Iterable from this filterable
|
default MapX<K,V> |
removeAllS(java.util.stream.Stream<? extends org.jooq.lambda.tuple.Tuple2<K,V>> stream)
Remove all elements in the supplied Stream from this filterable
|
default MapX<K,V> |
retainAll(org.jooq.lambda.tuple.Tuple2<K,V>... values)
Retain only the supplied elements in the returned Filters
|
default MapX<K,V> |
retainAllI(java.lang.Iterable<? extends org.jooq.lambda.tuple.Tuple2<K,V>> it)
Retain only the supplied elements in the returned Filters
|
default MapX<K,V> |
retainAllS(java.util.stream.Stream<? extends org.jooq.lambda.tuple.Tuple2<K,V>> stream)
Retain only the supplied elements in the returned Filters
|
int |
size() |
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,V>> |
stream() |
default void |
subscribe(org.reactivestreams.Subscriber<? super org.jooq.lambda.tuple.Tuple2<K,V>> s) |
default <T> DequeX<T> |
toDequeX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a DequeX via the provided transformation function
|
default <T> ListX<T> |
toListX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a ListX via the provided transformation function
|
static <K,V> java.util.stream.Collector<org.jooq.lambda.tuple.Tuple2<? extends K,? extends V>,?,java.util.Map<K,V>> |
toMapX() |
default <T> QueueX<T> |
toQueueX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a QueueX via the provided transformation function
|
default <T> SetX<T> |
toSetX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a SetX via the provided transformation function
|
default <T> SortedSetX<T> |
toSortedSetX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
Convert this MapX to a SortedSetX via the provided transformation function
|
default <R> MapX<K,R> |
trampoline(java.util.function.Function<? super V,? extends Trampoline<? extends R>> mapper)
Performs a map operation that can call a recursive method without running out of stack space
|
unwrap, unwrapIfInstance, unwrapNested
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, values
retry, retry
collect, collectors, commonPrefix, commonSuffix, count, count, countDistinct, countDistinct, countDistinctBy, countDistinctBy, maxBy, minBy, mode, sum, sumDouble, sumInt, sumLong, to, toList, toMap, toMap, toSet, toString, toString
endsWith, endsWithIterable, findAny, findFirst, firstValue, foldLeft, foldLeft, foldLeft, foldLeft, foldRight, foldRight, foldRight, foldRightMapToType, get, groupBy, join, join, join, mapReduce, mapReduce, print, print, printErr, printOut, reduce, reduce, reduce, reduce, reduce, reduce, reduce, schedule, scheduleFixedDelay, scheduleFixedRate, single, single, singleUnsafe, startsWith, startsWithIterable, takeOne, xMatch
forEach, forEach, forEach, forEach, forEach, forEachSubscribe, forEachSubscribe, forEachSubscribe
static <K,V> java.util.stream.Collector<org.jooq.lambda.tuple.Tuple2<? extends K,? extends V>,?,java.util.Map<K,V>> defaultCollector()
static <K,V> java.util.stream.Collector<org.jooq.lambda.tuple.Tuple2<? extends K,? extends V>,?,java.util.Map<K,V>> immutableCollector()
static <K,V> java.util.stream.Collector<org.jooq.lambda.tuple.Tuple2<? extends K,? extends V>,?,java.util.Map<K,V>> toMapX()
<K,V> java.util.stream.Collector<org.jooq.lambda.tuple.Tuple2<? extends K,? extends V>,?,java.util.Map<K,V>> getCollector()
default ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,V>> stream()
static <K,V> MapX<K,V> empty()
static <K,V> MapX<K,V> fromMap(java.util.Map<? extends K,? extends V> map)
map
- to wrapstatic <K,V> MapX<K,V> fromMap(java.util.stream.Collector<org.jooq.lambda.tuple.Tuple2<? extends K,? extends V>,?,java.util.Map<K,V>> collector, java.util.Map<? extends K,? extends V> map)
collector
- To generate new MapX's frommap
- to wrapdefault MapX<K,V> fromStream(ReactiveSeq<org.jooq.lambda.tuple.Tuple2<K,V>> stream)
stream
- ot Tuples to convert into a MapXdefault <KR,VR> MapX<KR,VR> flatMap(java.util.function.BiFunction<? super K,? super V,? extends MapX<KR,VR>> fn)
default <R> MapX<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 <R1,R2> MapX<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 boolean allMatch(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> c)
CyclopsCollectable
assertThat(ReactiveSeq.of(1,2,3,4,5).allMatch(it-> it>0 && it <6),equalTo(true));
allMatch
in interface CyclopsCollectable<org.jooq.lambda.tuple.Tuple2<K,V>>
c
- Predicate to check if all matchdefault boolean anyMatch(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> c)
CyclopsCollectable
ReactiveSeq.of(1,2,3,4,5).anyMatch(it-> it.equals(3))
//true
anyMatch
in interface CyclopsCollectable<org.jooq.lambda.tuple.Tuple2<K,V>>
c
- Predicate to check if any matchdefault boolean noneMatch(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> c)
noneMatch
in interface CyclopsCollectable<org.jooq.lambda.tuple.Tuple2<K,V>>
default java.util.Optional<org.jooq.lambda.tuple.Tuple2<K,V>> max(java.util.Comparator<? super org.jooq.lambda.tuple.Tuple2<K,V>> comparator)
CyclopsCollectable
max
in interface CyclopsCollectable<org.jooq.lambda.tuple.Tuple2<K,V>>
default java.util.Optional<org.jooq.lambda.tuple.Tuple2<K,V>> min(java.util.Comparator<? super org.jooq.lambda.tuple.Tuple2<K,V>> comparator)
CyclopsCollectable
min
in interface CyclopsCollectable<org.jooq.lambda.tuple.Tuple2<K,V>>
default MapX<K,V> plusAll(java.util.Map<? extends K,? extends V> map)
plusAll
in interface FluentMapX<K,V>
default MapX<K,V> minus(java.lang.Object key)
minus
in interface FluentMapX<K,V>
default MapX<K,V> minusAll(java.util.Collection<?> keys)
minusAll
in interface FluentMapX<K,V>
default <U> MapX<K,U> cast(java.lang.Class<? extends U> type)
Transformable
ClassCastException
.
// ClassCastException ReactiveSeq.of(1, "a", 2, "b", 3).cast(Integer.class)cast
in interface Transformable<V>
default MapX<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 Transformabledefault <R> MapX<K,R> trampoline(java.util.function.Function<? super V,? extends Trampoline<? extends R>> mapper)
Transformable
ReactiveSeq.of(10,20,30,40)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
Trampoline<Long> fibonacci(int i){
return fibonacci(i,1,0);
}
Trampoline<Long> fibonacci(int n, long a, long b) {
return n == 0 ? Trampoline.done(b) : Trampoline.more( ()->fibonacci(n-1, a+b, a));
}
55
6765
832040
102334155
ReactiveSeq.of(10_000,200_000,3_000_000,40_000_000)
.trampoline(i-> fibonacci(i))
.forEach(System.out::println);
completes successfully
trampoline
in interface Transformable<V>
mapper
- TCO Transformation functiondefault MapX<K,V> filter(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> fn)
Filters
of(1,2,3).filter(i->i>2);
//[3]
default MapX<K,V> filterNot(java.util.function.Predicate<? super org.jooq.lambda.tuple.Tuple2<K,V>> fn)
Filters
of(1,2,3).filter(i->i>2);
//[1,2]
default MapX<K,V> notNull()
Filters
of(1,2,null,4).nonNull();
//[1,2,4]
default MapX<K,V> removeAllS(java.util.stream.Stream<? extends org.jooq.lambda.tuple.Tuple2<K,V>> stream)
IterableFilterable
removeAllS
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
stream
- of elements to removedefault MapX<K,V> removeAllI(java.lang.Iterable<? extends org.jooq.lambda.tuple.Tuple2<K,V>> it)
IterableFilterable
removeAllI
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
it
- an Iterable of elements to removedefault MapX<K,V> removeAll(org.jooq.lambda.tuple.Tuple2<K,V>... values)
IterableFilterable
removeAll
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
values
- to removedefault MapX<K,V> retainAllI(java.lang.Iterable<? extends org.jooq.lambda.tuple.Tuple2<K,V>> it)
IterableFilterable
retainAllI
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
it
- Iterable of elements to retaindefault MapX<K,V> retainAllS(java.util.stream.Stream<? extends org.jooq.lambda.tuple.Tuple2<K,V>> stream)
IterableFilterable
retainAllS
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
stream
- of elements to retaindefault MapX<K,V> retainAll(org.jooq.lambda.tuple.Tuple2<K,V>... values)
IterableFilterable
retainAll
in interface IterableFilterable<org.jooq.lambda.tuple.Tuple2<K,V>>
values
- elements to retaindefault MapX<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 <U1,U2> MapX<U1,U2> bicast(java.lang.Class<U1> type1, java.lang.Class<U2> type2)
BiTransformable
MapX<Animal,Food> map = MapXs.of(cow,grass);
MapX<Mamaml,Vegitation> herbervoreMammals = map.bicast(Mammal.class,Vegitation.class);
bicast
in interface BiTransformable<K,V>
default <R1,R2> MapX<R1,R2> bitrampoline(java.util.function.Function<? super K,? extends Trampoline<? extends R1>> mapper1, java.util.function.Function<? super V,? extends Trampoline<? extends R2>> mapper2)
BiTransformable
bitrampoline
in interface BiTransformable<K,V>
mapper1
- transformation function for the first typemapper2
- transformation function for the second typedefault void subscribe(org.reactivestreams.Subscriber<? super org.jooq.lambda.tuple.Tuple2<K,V>> s)
default MapX<K,V> onEmpty(org.jooq.lambda.tuple.Tuple2<K,V> value)
OnEmpty
default MapX<K,V> onEmptyGet(java.util.function.Supplier<? extends org.jooq.lambda.tuple.Tuple2<K,V>> supplier)
OnEmpty
onEmptyGet
in interface OnEmpty<org.jooq.lambda.tuple.Tuple2<K,V>>
supplier
- to determine new value for containerdefault <X extends java.lang.Throwable> MapX<K,V> onEmptyThrow(java.util.function.Supplier<? extends X> supplier)
OnEmpty
onEmptyThrow
in interface OnEmpty<org.jooq.lambda.tuple.Tuple2<K,V>>
supplier
- to create exception fromdefault MapX<K,V> onEmptySwitch(java.util.function.Supplier<? extends java.util.Map<K,V>> supplier)
OnEmptySwitch
ListX.zero().onEmptySwitch(()->ListX.of(1));
onEmptySwitch
in interface OnEmptySwitch<org.jooq.lambda.tuple.Tuple2<K,V>,java.util.Map<K,V>>
supplier
- to create replacement containerdefault <T> ListX<T> toListX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a singleUnsafe valuedefault <T> SetX<T> toSetX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a singleUnsafe valuedefault <T> SortedSetX<T> toSortedSetX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a singleUnsafe valuedefault <T> QueueX<T> toQueueX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a singleUnsafe valuedefault <T> DequeX<T> toDequeX(java.util.function.Function<? super org.jooq.lambda.tuple.Tuple2<? super K,? super V>,? extends T> fn)
fn
- Mapping function to transform each Map entry into a singleUnsafe value