Skip to content

Commit

Permalink
Add generic T to static asDomainEventMessage function
Browse files Browse the repository at this point in the history
Add generic T to static asDomainEventMessage function for the payload type of the EventMessage.
Doing so will result that a call to asDomainEventMessage will return a DomainEventMessage<T> rather than a DomainEventMessage with an unknown payload
  • Loading branch information
smcvb committed Dec 28, 2016
1 parent ec64445 commit 60bbd84
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -75,11 +75,12 @@ public static <T> TrackedEventMessage<T> asTrackedEventMessage(EventMessage<T> e
* {@code null} type, aggegrateIdentifier equal to messageIdentifier and sequence number of 0L. * {@code null} type, aggegrateIdentifier equal to messageIdentifier and sequence number of 0L.
* *
* @param eventMessage the input event message * @param eventMessage the input event message
* @param <T> The type of payload in the message
* @return the message converted to a domain event message * @return the message converted to a domain event message
*/ */
public static DomainEventMessage<?> asDomainEventMessage(EventMessage<?> eventMessage) { public static <T> DomainEventMessage<T> asDomainEventMessage(EventMessage<T> eventMessage) {
if (eventMessage instanceof DomainEventMessage<?>) { if (eventMessage instanceof DomainEventMessage<?>) {
return (DomainEventMessage<?>) eventMessage; return (DomainEventMessage<T>) eventMessage;
} }
return new GenericDomainEventMessage<>(null, eventMessage.getIdentifier(), 0L, eventMessage, return new GenericDomainEventMessage<>(null, eventMessage.getIdentifier(), 0L, eventMessage,
eventMessage::getTimestamp); eventMessage::getTimestamp);
Expand Down

0 comments on commit 60bbd84

Please sign in to comment.