public class MapStream<K,V> extends java.lang.Object implements java.util.stream.Stream<UberMaps.Entry<K,V>>
| Constructor and Description |
|---|
MapStream(java.util.Map<K,V> map) |
MapStream(java.util.stream.Stream<? extends java.util.Map.Entry<K,V>> actual) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
allMatch(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate) |
boolean |
anyMatch(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate) |
void |
close() |
<R,A> R |
collect(java.util.stream.Collector<? super UberMaps.Entry<K,V>,A,R> collector) |
<R> R |
collect(java.util.function.Supplier<R> supplier,
java.util.function.BiConsumer<R,? super UberMaps.Entry<K,V>> accumulator,
java.util.function.BiConsumer<R,R> combiner) |
long |
count() |
MapStream<K,V> |
distinct() |
MapStream<K,V> |
distinctValues()
Only the entries with unique value are preserved in the stream.
|
MapStream<K,V> |
drop(java.util.function.BiPredicate<K,V> predicate)
Each entry in the stream are matched as key/value pair against the specified predicate.
|
MapStream<K,V> |
drop(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate)
All the entries that do match specified predicate are removed from the stream.
|
MapStream<K,V> |
dropKey(java.util.function.Predicate<? super K> keyPredicate)
All the entries where key matches specified predicate are removed from the stream.
|
MapStream<K,V> |
dropValue(java.util.function.Predicate<? super V> valPredicate)
All the entries where value matches specified predicate are removed from the stream.
|
MapStream<K,V> |
filter(java.util.function.BiPredicate<K,V> predicate)
Each entry in the stream are matched as key/value pair against the specified predicate.
|
MapStream<K,V> |
filter(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate) |
MapStream<K,V> |
filterKey(java.util.function.Predicate<? super K> keyPredicate)
Filter out only the entries where key matches specified predicate.
|
<R extends K> |
filterKeyByClass(java.lang.Class<R> filteredKeyClass)
Filter only the keys that are instances of the specified class (or nulls) and cast them to the specified type.
|
MapStream<K,V> |
filterValue(java.util.function.Predicate<? super V> valPredicate)
Filter out only the entries where value matches specified predicate.
|
<R extends V> |
filterValueByClass(java.lang.Class<R> filteredValueClass)
Filter only the values that are instances of the specified class (or nulls) and cast them to the specified type.
|
java.util.Optional<UberMaps.Entry<K,V>> |
find(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate)
Find first entry that matches specified predicate.
|
java.util.Optional<UberMaps.Entry<K,V>> |
findAny() |
java.util.Optional<UberMaps.Entry<K,V>> |
findByKey(K key)
Find first entry where key is equal to the specified object.
|
java.util.Optional<UberMaps.Entry<K,V>> |
findFirst() |
java.util.Optional<UberMaps.Entry<K,V>> |
findKey(java.util.function.Predicate<? super K> keyPredicate)
Find first entry where key matches specified predicate.
|
<R> UberStream<R> |
flatMap(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.stream.Stream<? extends R>> mapper) |
<K2,V2> MapStream<K2,V2> |
flatMapEntry(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.Map<K2,V2>> mapper)
Each entry in the stream is mapped by the specified function into another map.
|
<K2> MapStream<K2,V> |
flatMapKey(java.util.function.Function<? super K,? extends java.util.Collection<? extends K2>> mapper)
For each entry in the stream - key is mapped by the specified function into a collection.
|
java.util.stream.DoubleStream |
flatMapToDouble(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.stream.DoubleStream> mapper) |
java.util.stream.IntStream |
flatMapToInt(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.stream.IntStream> mapper) |
java.util.stream.LongStream |
flatMapToLong(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.stream.LongStream> mapper) |
void |
forEach(java.util.function.BiConsumer<K,V> action)
Each entry in the stream are passed as key/value pair into the specified consumer.
|
void |
forEach(java.util.function.Consumer<? super UberMaps.Entry<K,V>> action) |
void |
forEachKey(java.util.function.Consumer<? super K> action)
Specified consumer are called for each key in the stream.
|
void |
forEachOrdered(java.util.function.Consumer<? super UberMaps.Entry<K,V>> action) |
void |
forEachValue(java.util.function.Consumer<? super V> action)
Specified consumer are called for each value in the stream.
|
boolean |
isParallel() |
java.util.Iterator<UberMaps.Entry<K,V>> |
iterator() |
MapStream<K,V> |
limit(long maxSize) |
<R> UberStream<R> |
map(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends R> mapper) |
<K2,V2> MapStream<K2,V2> |
mapEntry(java.util.function.BiFunction<K,V,? extends java.util.Map.Entry<K2,V2>> mapper)
Each key/value pair in the stream is mapped by the specified BiFunction into another entry.
|
<K2,V2> MapStream<K2,V2> |
mapEntry(java.util.function.Function<? super K,? extends K2> keyMapper,
java.util.function.Function<? super V,? extends V2> valMapper)
For each entry in the stream - key is mapped by the specified key mapper function, and value is mapped
by the specified value mapper function.
|
<K2,V2> MapStream<K2,V2> |
mapEntry(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.Map.Entry<K2,V2>> mapper)
Each entry in the stream is mapped by the specified function into another entry.
|
<K2> MapStream<K2,V> |
mapKey(java.util.function.Function<? super K,? extends K2> keyMapper)
For each entry in the stream - key is mapped by the specified key mapper function, value is untouched.
|
java.util.stream.DoubleStream |
mapToDouble(java.util.function.ToDoubleFunction<? super UberMaps.Entry<K,V>> mapper) |
java.util.stream.IntStream |
mapToInt(java.util.function.ToIntFunction<? super UberMaps.Entry<K,V>> mapper) |
java.util.stream.LongStream |
mapToLong(java.util.function.ToLongFunction<? super UberMaps.Entry<K,V>> mapper) |
<V2> MapStream<K,V2> |
mapValue(java.util.function.Function<? super V,? extends V2> valMapper)
For each entry in the stream - key is untouched, and value is mapped by the specified value mapper function.
|
java.util.Optional<UberMaps.Entry<K,V>> |
max(java.util.Comparator<? super UberMaps.Entry<K,V>> comparator) |
java.util.Optional<UberMaps.Entry<K,V>> |
min(java.util.Comparator<? super UberMaps.Entry<K,V>> comparator) |
boolean |
noneMatch(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate) |
MapStream<K,V> |
onClose(java.lang.Runnable closeHandler) |
MapStream<K,V> |
parallel() |
MapStream<K,V> |
peek(java.util.function.Consumer<? super UberMaps.Entry<K,V>> action) |
MapStream<K,V> |
peekKeys(java.util.function.Consumer<? super K> action)
Specified consumer are called for each key in the stream.
|
MapStream<K,V> |
peekValues(java.util.function.Consumer<? super V> action)
Specified consumer are called for each value in the stream.
|
java.util.Optional<UberMaps.Entry<K,V>> |
reduce(java.util.function.BinaryOperator<UberMaps.Entry<K,V>> accumulator) |
UberMaps.Entry<K,V> |
reduce(UberMaps.Entry<K,V> identity,
java.util.function.BinaryOperator<UberMaps.Entry<K,V>> accumulator) |
<U> U |
reduce(U identity,
java.util.function.BiFunction<U,? super UberMaps.Entry<K,V>,U> accumulator,
java.util.function.BinaryOperator<U> combiner) |
MapStream<K,V> |
sequential() |
MapStream<K,V> |
skip(long n) |
MapStream<K,V> |
sorted() |
MapStream<K,V> |
sorted(java.util.Comparator<? super UberMaps.Entry<K,V>> comparator) |
MapStream<K,V> |
sortedKeys(java.util.Comparator<? super K> comparator)
All entries in the stream are sorted by comparing keys using specified comparator.
|
MapStream<K,V> |
sortedValues(java.util.Comparator<? super V> comparator)
All entries in the stream are sorted by comparing values using specified comparator.
|
java.util.Spliterator<UberMaps.Entry<K,V>> |
spliterator() |
<M extends java.util.Map<K,V>> |
to(java.util.function.Supplier<M> mapSupplier)
Collect stream into a map provided by the specified supplier.
|
java.lang.Object[] |
toArray() |
<A> A[] |
toArray(java.util.function.IntFunction<A[]> generator) |
UberStream<K> |
toKeys()
Map all entries in the stream by
UberMaps.Entry.getKey() method. |
java.util.Map<K,V> |
toLinkedMap()
Collect stream to the linked map.
|
java.util.Map<K,V> |
toMap()
Collect stream back to the map form.
|
UberStream<V> |
toValues()
Map all entries in the stream by
UberMaps.Entry.getValue() method. |
MapStream<K,V> |
unordered() |
public java.util.Iterator<UberMaps.Entry<K,V>> iterator()
iterator in interface java.util.stream.BaseStream<UberMaps.Entry<K,V>,java.util.stream.Stream<UberMaps.Entry<K,V>>>public java.util.Spliterator<UberMaps.Entry<K,V>> spliterator()
spliterator in interface java.util.stream.BaseStream<UberMaps.Entry<K,V>,java.util.stream.Stream<UberMaps.Entry<K,V>>>public boolean isParallel()
isParallel in interface java.util.stream.BaseStream<UberMaps.Entry<K,V>,java.util.stream.Stream<UberMaps.Entry<K,V>>>public MapStream<K,V> sequential()
sequential in interface java.util.stream.BaseStream<UberMaps.Entry<K,V>,java.util.stream.Stream<UberMaps.Entry<K,V>>>public MapStream<K,V> parallel()
parallel in interface java.util.stream.BaseStream<UberMaps.Entry<K,V>,java.util.stream.Stream<UberMaps.Entry<K,V>>>public MapStream<K,V> unordered()
unordered in interface java.util.stream.BaseStream<UberMaps.Entry<K,V>,java.util.stream.Stream<UberMaps.Entry<K,V>>>public MapStream<K,V> onClose(java.lang.Runnable closeHandler)
onClose in interface java.util.stream.BaseStream<UberMaps.Entry<K,V>,java.util.stream.Stream<UberMaps.Entry<K,V>>>public void close()
close in interface java.lang.AutoCloseableclose in interface java.util.stream.BaseStream<UberMaps.Entry<K,V>,java.util.stream.Stream<UberMaps.Entry<K,V>>>public MapStream<K,V> filter(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate)
filter in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public MapStream<K,V> filter(java.util.function.BiPredicate<K,V> predicate)
public MapStream<K,V> filterKey(java.util.function.Predicate<? super K> keyPredicate)
public MapStream<K,V> filterValue(java.util.function.Predicate<? super V> valPredicate)
public <R extends K> MapStream<R,V> filterKeyByClass(java.lang.Class<R> filteredKeyClass)
Filter only the keys that are instances of the specified class (or nulls) and cast them to the specified type.
Note: nulls survive the filtering!
Use separate filters to drop nulls!
public <R extends V> MapStream<K,R> filterValueByClass(java.lang.Class<R> filteredValueClass)
Filter only the values that are instances of the specified class (or nulls) and cast them to the specified type.
Note: nulls survive the filtering!
Use separate filters to drop nulls!
public MapStream<K,V> drop(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate)
public MapStream<K,V> drop(java.util.function.BiPredicate<K,V> predicate)
public MapStream<K,V> dropKey(java.util.function.Predicate<? super K> keyPredicate)
public MapStream<K,V> dropValue(java.util.function.Predicate<? super V> valPredicate)
public <R> UberStream<R> map(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends R> mapper)
map in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public <K2,V2> MapStream<K2,V2> mapEntry(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.Map.Entry<K2,V2>> mapper)
public <K2,V2> MapStream<K2,V2> mapEntry(java.util.function.BiFunction<K,V,? extends java.util.Map.Entry<K2,V2>> mapper)
public <K2,V2> MapStream<K2,V2> mapEntry(java.util.function.Function<? super K,? extends K2> keyMapper, java.util.function.Function<? super V,? extends V2> valMapper)
public <K2> MapStream<K2,V> mapKey(java.util.function.Function<? super K,? extends K2> keyMapper)
public <V2> MapStream<K,V2> mapValue(java.util.function.Function<? super V,? extends V2> valMapper)
public java.util.stream.IntStream mapToInt(java.util.function.ToIntFunction<? super UberMaps.Entry<K,V>> mapper)
mapToInt in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public java.util.stream.LongStream mapToLong(java.util.function.ToLongFunction<? super UberMaps.Entry<K,V>> mapper)
mapToLong in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public java.util.stream.DoubleStream mapToDouble(java.util.function.ToDoubleFunction<? super UberMaps.Entry<K,V>> mapper)
mapToDouble in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public <R> UberStream<R> flatMap(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.stream.Stream<? extends R>> mapper)
flatMap in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public <K2,V2> MapStream<K2,V2> flatMapEntry(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.Map<K2,V2>> mapper)
public <K2> MapStream<K2,V> flatMapKey(java.util.function.Function<? super K,? extends java.util.Collection<? extends K2>> mapper)
Map map = {1=10, 2=20};
Map map2 = new MapStream(map).flatMapKey(i -> asList(i, i * 10)).collect();
System.out.println(map2); // {1=10, 10=10, 2=20, 20=20}
public java.util.stream.IntStream flatMapToInt(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.stream.IntStream> mapper)
flatMapToInt in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public java.util.stream.LongStream flatMapToLong(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.stream.LongStream> mapper)
flatMapToLong in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public java.util.stream.DoubleStream flatMapToDouble(java.util.function.Function<? super UberMaps.Entry<K,V>,? extends java.util.stream.DoubleStream> mapper)
flatMapToDouble in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public MapStream<K,V> distinct()
distinct in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public MapStream<K,V> distinctValues()
public MapStream<K,V> sorted()
sorted in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public MapStream<K,V> sorted(java.util.Comparator<? super UberMaps.Entry<K,V>> comparator)
sorted in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public MapStream<K,V> sortedKeys(java.util.Comparator<? super K> comparator)
public MapStream<K,V> sortedValues(java.util.Comparator<? super V> comparator)
public MapStream<K,V> peek(java.util.function.Consumer<? super UberMaps.Entry<K,V>> action)
peek in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public MapStream<K,V> peekKeys(java.util.function.Consumer<? super K> action)
public MapStream<K,V> peekValues(java.util.function.Consumer<? super V> action)
public MapStream<K,V> limit(long maxSize)
limit in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public MapStream<K,V> skip(long n)
skip in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public void forEach(java.util.function.Consumer<? super UberMaps.Entry<K,V>> action)
forEach in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public void forEach(java.util.function.BiConsumer<K,V> action)
public void forEachKey(java.util.function.Consumer<? super K> action)
public void forEachValue(java.util.function.Consumer<? super V> action)
public void forEachOrdered(java.util.function.Consumer<? super UberMaps.Entry<K,V>> action)
forEachOrdered in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public UberStream<K> toKeys()
UberMaps.Entry.getKey() method.public UberStream<V> toValues()
UberMaps.Entry.getValue() method.public java.lang.Object[] toArray()
toArray in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public <A> A[] toArray(java.util.function.IntFunction<A[]> generator)
toArray in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public UberMaps.Entry<K,V> reduce(UberMaps.Entry<K,V> identity, java.util.function.BinaryOperator<UberMaps.Entry<K,V>> accumulator)
reduce in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public java.util.Optional<UberMaps.Entry<K,V>> reduce(java.util.function.BinaryOperator<UberMaps.Entry<K,V>> accumulator)
reduce in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public <U> U reduce(U identity,
java.util.function.BiFunction<U,? super UberMaps.Entry<K,V>,U> accumulator,
java.util.function.BinaryOperator<U> combiner)
reduce in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public java.util.Map<K,V> toMap()
MapCollectors.toMap()public java.util.Map<K,V> toLinkedMap()
MapCollectors.toMap()public <M extends java.util.Map<K,V>> M to(java.util.function.Supplier<M> mapSupplier)
MapCollectors.toMap()public <R> R collect(java.util.function.Supplier<R> supplier,
java.util.function.BiConsumer<R,? super UberMaps.Entry<K,V>> accumulator,
java.util.function.BiConsumer<R,R> combiner)
collect in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public <R,A> R collect(java.util.stream.Collector<? super UberMaps.Entry<K,V>,A,R> collector)
collect in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public java.util.Optional<UberMaps.Entry<K,V>> min(java.util.Comparator<? super UberMaps.Entry<K,V>> comparator)
min in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public java.util.Optional<UberMaps.Entry<K,V>> max(java.util.Comparator<? super UberMaps.Entry<K,V>> comparator)
max in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public long count()
count in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public boolean anyMatch(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate)
anyMatch in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public boolean allMatch(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate)
allMatch in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public boolean noneMatch(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate)
noneMatch in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public java.util.Optional<UberMaps.Entry<K,V>> findFirst()
findFirst in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public java.util.Optional<UberMaps.Entry<K,V>> findAny()
findAny in interface java.util.stream.Stream<UberMaps.Entry<K,V>>public java.util.Optional<UberMaps.Entry<K,V>> find(java.util.function.Predicate<? super UberMaps.Entry<K,V>> predicate)
public java.util.Optional<UberMaps.Entry<K,V>> findKey(java.util.function.Predicate<? super K> keyPredicate)
public java.util.Optional<UberMaps.Entry<K,V>> findByKey(K key)