Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public interface Stream<T>
A stream here is sequential and lazy: each stage pulls one element at a
time from the one before it, and only when a terminal operation asks. So
an infinite iterate or generate behind a limit ends, findFirst
and the anyMatch family stop at the element that decides them, and the
side effects of peek happen element by element, in encounter order.
What is not here: spliterators, and with them parallel evaluation.
parallel() answers the stream it was called on.
Nested types
interface Stream.Builder | java.util.stream.Stream.Builder: collects elements, then answers them as a stream, once. |
Methods
Inherited methods
From BaseStream
iterator, isParallel, sequential, parallel, unordered, onClose, close
Method details
filter
public abstract Stream<T> filter(Predicate<? super T> predicate)map
public abstract <R> Stream<R> map(Function<? super T, ? extends R> mapper)mapToInt
public abstract IntStream mapToInt(ToIntFunction<? super T> mapper)mapToLong
public abstract LongStream mapToLong(ToLongFunction<? super T> mapper)mapToDouble
public abstract DoubleStream mapToDouble(ToDoubleFunction<? super T> mapper)flatMap
public abstract <R> Stream<R> flatMap(Function<? super T, ? extends Stream<? extends R>> mapper)flatMapToInt
public abstract IntStream flatMapToInt(Function<? super T, ? extends IntStream> mapper)flatMapToLong
public abstract LongStream flatMapToLong(Function<? super T, ? extends LongStream> mapper)flatMapToDouble
public abstract DoubleStream flatMapToDouble(Function<? super T, ? extends DoubleStream> mapper)distinct
public abstract Stream<T> distinct()sorted
public abstract Stream<T> sorted()sorted
public abstract Stream<T> sorted(Comparator<? super T> comparator)peek
public abstract Stream<T> peek(Consumer<? super T> action)limit
public abstract Stream<T> limit(long maxSize)skip
public abstract Stream<T> skip(long n)takeWhile
public abstract Stream<T> takeWhile(Predicate<? super T> predicate)dropWhile
public abstract Stream<T> dropWhile(Predicate<? super T> predicate)forEach
public abstract void forEach(Consumer<? super T> action)forEachOrdered
public abstract void forEachOrdered(Consumer<? super T> action)toArray
public abstract Object[] toArray()toArray
public abstract <A> A[] toArray(IntFunction<A[]> generator)reduce
public abstract T reduce(T identity, BinaryOperator<T> accumulator)reduce
public abstract Optional<T> reduce(BinaryOperator<T> accumulator)reduce
public abstract <U> U reduce(U identity, BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner)collect
public abstract <R> R collect(Supplier<R> supplier, BiConsumer<R, ? super T> accumulator, BiConsumer<R, R> combiner)collect
public abstract <R, A> R collect(Collector<? super T, A, R> collector)toList
public default List<T> toList()An unmodifiable list of the elements, which may be null.
min
public abstract Optional<T> min(Comparator<? super T> comparator)max
public abstract Optional<T> max(Comparator<? super T> comparator)count
public abstract long count()anyMatch
public abstract boolean anyMatch(Predicate<? super T> predicate)allMatch
public abstract boolean allMatch(Predicate<? super T> predicate)noneMatch
public abstract boolean noneMatch(Predicate<? super T> predicate)findFirst
public abstract Optional<T> findFirst()findAny
public abstract Optional<T> findAny()builder
public static <T> Stream.Builder<T> builder()empty
public static <T> Stream<T> empty()of
public static <T> Stream<T> of(T t)ofNullable
public static <T> Stream<T> ofNullable(T t)of
public static <T> Stream<T> of(T... values)iterate
public static <T> Stream<T> iterate(T seed, UnaryOperator<T> f)iterate
public static <T> Stream<T> iterate(T seed, Predicate<? super T> hasNext, UnaryOperator<T> next)generate
public static <T> Stream<T> generate(Supplier<? extends T> s)concat
public static <T> Stream<T> concat(Stream<? extends T> a, Stream<? extends T> b)