T - The type over which the streamable's streams stream.public interface Streamable<T>
extends java.util.function.Supplier<java.util.stream.Stream<T>>
| Modifier and Type | Method and Description |
|---|---|
default <O> O |
collect(java.util.stream.Collector<T,?,O> collector)
Stream this streamable, and collect the stream with the supplied collector.
|
default Streamable<T> |
concat(Streamable<T> streamable)
Concatenate this streamable with another streamable.
|
static <T> Streamable<T> |
empty()
Gets an empty streamable.
|
default Streamable<T> |
filter(java.util.function.Predicate<? super T> predicate)
Transform this streamable's streams with the supplied filter predicate.
|
default <T2> Streamable<T2> |
flatMap(java.util.function.Function<? super T,java.util.stream.Stream<? extends T2>> f)
Transform this streamable's streams with the supplied flatmap.
|
default void |
forEach(java.util.function.Consumer<T> action)
Stream this streamable, and call forEach on the resulting stream with the supplied action.
|
default void |
forEachOrdered(java.util.function.Consumer<T> action)
Stream this streamable, and call forEach on the resulting stream in order with the supplied action.
|
default Streamable<T> |
limit(long n)
Transform this streamable's streams by limiting the number of elements they can contain.
|
default <T2> Streamable<T2> |
map(java.util.function.Function<? super T,? extends T2> f)
Transform this streamable's streams with the supplied map.
|
static <T> Streamable<T> |
of(java.util.Collection<T> collection)
Create a streamable that produces streams over a collection of items.
|
static <T> Streamable<T> |
of(java.lang.Iterable<T> iterable)
Create a streamable that produces streams over an iterable of items.
|
static <T> Streamable<T> |
of(java.util.Optional<T> optional)
Create a streamable that produces streams of 0 or 1 elements over an optional value.
|
static <T> Streamable<T> |
of(java.util.function.Supplier<java.util.stream.Stream<T>> streamable)
For converting method references to no-arg methods that return streams into streamable.
|
static <T> Streamable<T> |
of(T... items)
Create a streamable that produces streams over an array of items.
|
static <T> Streamable<T> |
ofAll(Streamable<T>... streamables)
Concatenate a series of streamables together.
|
default Streamable<T> |
reject(java.util.function.Predicate<? super T> predicate)
Transform this streamable's streams with the supplied filter predicate, rejecting items which match the predicate.
|
default Streamable<T> |
skip(long n)
Transform this streamable's streams by skipping elements
|
default Streamable<T> |
sorted(java.util.Comparator<? super T> comparator)
Transform this streamable's streams by sorting them.
|
default java.util.stream.Stream<T> |
stream()
Synonym for "get"
|
default T[] |
toArray(java.util.function.IntFunction<T[]> arrayConstructor)
Stream this streamable, and collect the stream to an array.
|
default java.util.List<T> |
toList()
Stream this streamable, and collect the stream to a list.
|
default <K> java.util.Map<K,T> |
toMap(java.util.function.Function<? super T,? extends K> indexFunction)
Stream this streamable, and collect the stream to a map, extracting keys with the supplied index function.
|
default <K,V> java.util.Map<K,V> |
toMap(java.util.function.Function<? super T,? extends K> keyFunction,
java.util.function.Function<? super T,? extends V> valueFunction)
Stream this streamable, and collect the stream to a map, extracting keys and values with the supplied functions.
|
default java.util.Set<T> |
toSet()
Stream this streamable, and collect the stream to a set.
|
default <T2> Streamable<T2> |
transform(java.util.function.Function<java.util.stream.Stream<T>,java.util.stream.Stream<T2>> transformer)
Create a streamable that transforms the streams produced by this streamable with a stream transformer.
|
static <T> Streamable<T> empty()
T - The type of the values that aren't in the streamable's streams.static <T> Streamable<T> of(java.util.function.Supplier<java.util.stream.Stream<T>> streamable)
T - The type over which the streamable's streams stream.streamable - Anything that can be cast to a Streamable.static <T> Streamable<T> of(T... items)
T - The type of the values in the array.items - The items that the streamable's streams will stream.static <T> Streamable<T> of(java.util.Collection<T> collection)
T - The type of the values in the collection.collection - The items that the streamable's streams will stream.static <T> Streamable<T> of(java.lang.Iterable<T> iterable)
T - The type of the values in the iterable.iterable - The items that the streamable's streams will stream.static <T> Streamable<T> of(java.util.Optional<T> optional)
T - The type of the optional.optional - The optional item that the streamable's streams will stream.@SafeVarargs static <T> Streamable<T> ofAll(Streamable<T>... streamables)
T - The type of the streamables.streamables - The streamables to concatenate.default java.util.stream.Stream<T> stream()
default Streamable<T> concat(Streamable<T> streamable)
streamable - The streamable to concatenate.default <T2> Streamable<T2> transform(java.util.function.Function<java.util.stream.Stream<T>,java.util.stream.Stream<T2>> transformer)
T2 - The type of the streams produced by the transformation.transformer - The transformer to apply to this streamable's streams.default <T2> Streamable<T2> map(java.util.function.Function<? super T,? extends T2> f)
T2 - The mapped-to type.f - The map to apply.default <T2> Streamable<T2> flatMap(java.util.function.Function<? super T,java.util.stream.Stream<? extends T2>> f)
T2 - The flatmapped-to type.f - The flatmap to apply.default Streamable<T> filter(java.util.function.Predicate<? super T> predicate)
predicate - The filter predicate to apply.default Streamable<T> reject(java.util.function.Predicate<? super T> predicate)
predicate - The filter predicate to apply.default Streamable<T> sorted(java.util.Comparator<? super T> comparator)
comparator - The comparator to use in sorting.default Streamable<T> skip(long n)
n - The number of elements to skipdefault Streamable<T> limit(long n)
n - The number of elements to limit to.default void forEach(java.util.function.Consumer<T> action)
action - The action to apply to each stream element.default void forEachOrdered(java.util.function.Consumer<T> action)
action - The action to apply to each stream element.default <O> O collect(java.util.stream.Collector<T,?,O> collector)
O - The output type of the collector.collector - The collector to use to collect streamed values.default java.util.List<T> toList()
default java.util.Set<T> toSet()
default <K> java.util.Map<K,T> toMap(java.util.function.Function<? super T,? extends K> indexFunction)
K - The type of the keys.indexFunction - The function to use to extract keys from the streamed values.default <K,V> java.util.Map<K,V> toMap(java.util.function.Function<? super T,? extends K> keyFunction, java.util.function.Function<? super T,? extends V> valueFunction)
K - The type of the keys.V - The type of the values.keyFunction - The function to use to extract keys from the stream.valueFunction - The function to use to extract values from the stream.Copyright © 2015. All Rights Reserved.