public interface NodeStream
extends net.kyori.lunar.CheckedAutoCloseable
nodes.Stream| Modifier and Type | Method and Description |
|---|---|
default <R,A> R |
collect(@NonNull java.util.stream.Collector<? super Node,A,R> collector)
Performs a mutable reduction operation on the nodes of this stream using a
Collector. |
static @NonNull NodeStream |
concat(@NonNull NodeStream a,
@NonNull NodeStream b)
Creates a lazily concatenated node stream whose elements are all the elements of the first stream followed by
all the elements of the second stream.
|
static @NonNull NodeStream |
empty()
Creates an empty node stream.
|
@NonNull NodeStream |
filter(@NonNull java.util.function.Predicate<? super Node> predicate)
Returns a stream consisting of the nodes of this stream that match the given predicate.
|
default @NonNull java.util.Optional<Node> |
findAny()
Returns an
Optional describing some node of the stream, or an empty Optional if the stream is empty. |
default @NonNull java.util.Optional<Node> |
findFirst()
Returns an
Optional describing the first node of this stream, or an empty Optional if the stream is empty. |
@NonNull NodeStream |
flatMap(@NonNull java.util.function.Function<? super Node,? extends NodeStream> function)
Returns a stream consisting of the results of replacing each node of this stream with the contents of a mapped stream
produced by applying the provided mapping function to each node.
|
default void |
forEach(@NonNull java.util.function.Consumer<? super Node> action)
Performs an action for each node of this stream.
|
default <R> java.util.stream.Stream<R> |
map(java.util.function.Function<? super Node,? extends R> mapper)
Returns a stream consisting of the results of applying the given
function to the nodes of this stream.
|
default @NonNull NodeStream |
named(@NonNull java.util.Collection<java.lang.String> names)
Returns a stream consisting of the nodes of this stream whose name is in
names. |
default @NonNull NodeStream |
named(java.lang.String... names)
Returns a stream consisting of the nodes of this stream whose name is in
names. |
default @NonNull NodeStream |
named(@NonNull java.lang.String name)
Returns a stream consisting of the nodes of this stream that are named
name. |
static @NonNull NodeStream |
of(@NonNull Node node)
Creates a node stream consisting of a single node.
|
static @NonNull NodeStream |
of(@NonNull java.util.stream.Stream<Node> stream)
Creates a node stream from a stream of nodes.
|
default @NonNull NodeStreamElement<Node> |
one()
Gets a stream element representing a single node.
|
@NonNull java.util.stream.Stream<Node> |
stream()
Gets the backing stream.
|
static @NonNull NodeStream empty()
static @NonNull NodeStream of(@NonNull Node node)
node - the nodestatic @NonNull NodeStream of(@NonNull java.util.stream.Stream<Node> stream)
stream - the streamstatic @NonNull NodeStream concat(@NonNull NodeStream a, @NonNull NodeStream b)
a - the first node streamb - the second node stream@NonNull java.util.stream.Stream<Node> stream()
@NonNull NodeStream filter(@NonNull java.util.function.Predicate<? super Node> predicate)
predicate - a non-interfering, stateless predicate to apply to each node to determine if it should be includedStream.filter(Predicate)default @NonNull NodeStream named(@NonNull java.lang.String name)
name.name - the namedefault @NonNull NodeStream named(java.lang.String... names)
names.names - the namesdefault @NonNull NodeStream named(@NonNull java.util.Collection<java.lang.String> names)
names.names - the namesdefault <R> java.util.stream.Stream<R> map(java.util.function.Function<? super Node,? extends R> mapper)
R - the type of the new streammapper - a non-interfering, stateless function to apply to each node@NonNull NodeStream flatMap(@NonNull java.util.function.Function<? super Node,? extends NodeStream> function)
function - a non-interfering, stateless function to apply to each node which produces a stream of new valuesStream.flatMap(Function)default void forEach(@NonNull java.util.function.Consumer<? super Node> action)
action - a non-interfering action to perform on the nodesStream.forEach(Consumer)default <R,A> R collect(@NonNull java.util.stream.Collector<? super Node,A,R> collector)
Collector.R - the type of the resultA - the intermediate accumulation type of the Collectorcollector - the collector describing the reductionStream.collect(Collector)default @NonNull java.util.Optional<Node> findAny()
Optional describing some node of the stream, or an empty Optional if the stream is empty.Stream.findAny()default @NonNull java.util.Optional<Node> findFirst()
Optional describing the first node of this stream, or an empty Optional if the stream is empty.Stream.findFirst()default @NonNull NodeStreamElement<Node> one()
java.lang.IllegalArgumentException - if the stream consists of two or more nodes