Interface MessageStream.Empty<M extends Message>
- Type Parameters:
M- The type ofMessagefor the emptyMessageStream.Entryof this stream.
- All Superinterfaces:
MessageStream<M>,MessageStream.Single<M>
- Enclosing interface:
MessageStream<M extends Message>
MessageStream implementation that completes normally or with an error without returning any elements.
Any operations that would map(Function) or MessageStream.reduce(Object, BiFunction) the stream will do
nothing at all for an empty MessageStream.
- Since:
- 5.0.0
- Author:
- Allard Buijze, Mateusz Nowak, Mitchell Herrijgers, Steven van Beelen
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.axonframework.messaging.core.MessageStream
MessageStream.Empty<M extends Message>, MessageStream.Entry<M extends Message>, MessageStream.Single<M extends Message> -
Method Summary
Modifier and TypeMethodDescriptiondefault <T extends Message>
MessageStream.Empty<T> cast()Casts this stream to the given type.default MessageStream<M> concatWith(MessageStream<M> other) Returns a stream that concatenates this stream with the givenotherstream, if this stream completes successfully.default MessageStream.Empty<M> first()Returns astreamthat includes only the first message ofthisstream, unless it completes without delivering any messages, in which case it completes the same way.default <RM extends Message>
MessageStream.Empty<RM> map(Function<MessageStream.Entry<M>, MessageStream.Entry<RM>> mapper) default <RM extends Message>
MessageStream.Empty<RM> mapMessage(Function<M, RM> mapper) default MessageStream.Empty<M> onComplete(Runnable completeHandler) Returns a stream that invokes the givencompleteHandlerwhen the stream completes normally.default MessageStream.Empty<M> onNext(Consumer<MessageStream.Entry<M>> onNext) Invokes the givenonNexteach time anentryis consumed from this stream.Methods inherited from interface org.axonframework.messaging.core.MessageStream
close, error, hasNextAvailable, ignoreEntries, isCompleted, next, onClose, onErrorContinue, peek, reduce, setCallbackMethods inherited from interface org.axonframework.messaging.core.MessageStream.Single
asCompletableFuture, filter
-
Method Details
-
first
Description copied from interface:MessageStreamReturns astreamthat includes only the first message ofthisstream, unless it completes without delivering any messages, in which case it completes the same way.When the first message is delivered, the returned stream completes normally, independently of how this stream completes. Upon consuming the first message, this stream is
MessageStream.close()immediately.- Specified by:
firstin interfaceMessageStream<M extends Message>- Specified by:
firstin interfaceMessageStream.Single<M extends Message>- Returns:
- A
streamthat includes only the first message ofthisstream.
-
map
default <RM extends Message> MessageStream.Empty<RM> map(@Nonnull Function<MessageStream.Entry<M>, MessageStream.Entry<RM>> mapper) Description copied from interface:MessageStreamReturns a stream that maps eachentryfrom this stream using givenmapperfunction into an entry carrying aMessageEntrywith aMessageof typeRM.The returned stream completes the same way
thisstream completes.- Specified by:
mapin interfaceMessageStream<M extends Message>- Specified by:
mapin interfaceMessageStream.Single<M extends Message>- Type Parameters:
RM- The declared type ofMessagecontained in the returnedentry.- Parameters:
mapper- The function convertingentriesfrom this stream from entries containingmessageof typeMtoRM.- Returns:
- A stream with all
entriesmapped according to themapperfunction.
-
mapMessage
Description copied from interface:MessageStreamReturns a stream that maps eachmessagefrom theentriesin this stream using the givenmapperfunction. This maps theMessagesfrom typeMto typeRM.The returned stream completes the same way
thisstream completes.- Specified by:
mapMessagein interfaceMessageStream<M extends Message>- Specified by:
mapMessagein interfaceMessageStream.Single<M extends Message>- Type Parameters:
RM- The declared type ofMessagecontained in the returnedentry.- Parameters:
mapper- The function convertingmessagefrom theentriesin this stream from typeMtoRM.- Returns:
- A stream with all
entriesmapped according to themapperfunction.
-
onNext
Description copied from interface:MessageStreamInvokes the givenonNexteach time anentryis consumed from this stream.Depending on the stream's implementation, the function may be invoked when the entry is provided to the
Consumer, or at the moment it's available for reading on the stream. Subscribing multiple times to the resulting stream may cause the givenonNextto be invoked more than once for an entry. -
concatWith
Description copied from interface:MessageStreamReturns a stream that concatenates this stream with the givenotherstream, if this stream completes successfully. Throws an exception if this stream is unbounded.When
thisstream completes with an error, so does the returned stream.- Specified by:
concatWithin interfaceMessageStream<M extends Message>- Parameters:
other- The MessageStream to append to this stream.- Returns:
- A stream concatenating this stream with given
other.
-
onComplete
Description copied from interface:MessageStreamReturns a stream that invokes the givencompleteHandlerwhen the stream completes normally. Throws an exception if this stream is unbounded.- Specified by:
onCompletein interfaceMessageStream<M extends Message>- Specified by:
onCompletein interfaceMessageStream.Single<M extends Message>- Parameters:
completeHandler- TheRunnableto invoke when the stream completes normally.- Returns:
- A stream that invokes the
completeHandlerupon normal completion.
-
cast
Description copied from interface:MessageStreamCasts this stream to the given type. This method is provided to be more flexible with generics. It is the caller's responsibility to ensure the cast is valid. Failure to do so may result inClassCastExceptionwhen reading elements.- Specified by:
castin interfaceMessageStream<M extends Message>- Specified by:
castin interfaceMessageStream.Single<M extends Message>- Type Parameters:
T- The type ofMessageto cast the MessageStream to.- Returns:
- This instance, cast to the given
Messageof typeT.
-