Class MessageStreamResolverUtils
MessageHandler
into the expected corresponding MessageStream.
This utility class currently has a major drawback, which is that it only takes the "top level" type into account.
Differently put, if we receive a Mono<Message> as the given result of
resolveToStream(Object, MessageTypeResolver), we will push that Message through the given
typeResolver and make it the Message.payload(). Similarly, if we receive a
CompletableFuture<List<Object>> (or CompletableFuture<List<Message>> for that matter), we will return
a MessageStream.Single, while we are actually dealing with a MessageStream.
These are known limitation that will be supported in due time.
- Since:
- 5.0.0
- Author:
- Simon Zambrovski, Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptionstatic MessageStream<?> resolveToStream(Object result, MessageTypeResolver typeResolver) Resolves the givenresultinto aMessageStream, using thetypeResolverwhen aMessageis constructed to define theMessageType.
-
Method Details
-
resolveToStream
public static MessageStream<?> resolveToStream(@Nullable Object result, @Nonnull MessageTypeResolver typeResolver) Resolves the givenresultinto aMessageStream, using thetypeResolverwhen aMessageis constructed to define theMessageType.Is able to switch between
Optional,CompletableFuture,Iterable,Stream,Mono, andFlux. If none of the above apply, or the givenresultisnull,MessageStream.just(Message)will be used.- Parameters:
result- The result to map into aMessageStream.typeResolver- TheMessageTypeResolverused to resolve theMessageTypeforMessagesthat are held in the returnedMessageStream.- Returns:
- A
MessageStreambased on the givenresult.
-