Interface MessageStreamResolver
- All Superinterfaces:
Function<Object,MessageStream<?>>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
MessageStream that carries it to the dispatcher.
The messageType the handler is subscribed for is given alongside the result, as it determines how many
Messages the handler may produce. Handlers of
CommandMessages produce exactly one result, so a
returned collection is carried as the payload of a single Message. Handlers of other message types may
produce several results, so a returned collection is spread over one Message per element.
This interface refines the Function that
HandlerDefinition.createHandler(Class, java.lang.reflect.Method, ParameterResolverFactory, Function) has
accepted since 5.0.0, so that it can be passed wherever that Function is expected. A
HandlerDefinition that forwards the Function it receives keeps the message type intact; one that
replaces it with a Function of its own falls back to apply(Object), which cannot know the message
type and therefore resolves as if the handler may produce several results.
- Since:
- 5.3.1
- Author:
- Mitchell Herrijgers
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault MessageStream<?> Resolves the givenresultwithout knowing which type ofMessagethe handler is subscribed for, and thus how manyMessagesit may produce.
-
Method Details
-
resolve
- Parameters:
result- the value returned byMessageHandlingMember.handle(Message, ProcessingContext, Object), possiblynullmessageType- the type ofMessagethe handler returning theresultis subscribed for- Returns:
- a
MessageStreamcarrying the givenresult
-
apply
Resolves the givenresultwithout knowing which type ofMessagethe handler is subscribed for, and thus how manyMessagesit may produce.Exists to satisfy the
Functioncontract for callers predatingresolve(Object, Class). Resolves as if the handler may produce several results, matching the behaviour of those callers. Preferresolve(Object, Class)whenever the message type is known.- Specified by:
applyin interfaceFunction<Object,MessageStream<?>> - Parameters:
result- the value returned byMessageHandlingMember.handle(Message, ProcessingContext, Object), possiblynull- Returns:
- a
MessageStreamcarrying the givenresult
-