@Test void testConstructor() { ResetContext<Object> messageOne = asResetContext(TEST_PAYLOAD); ResetContext<Object> messageTwo = asResetContext(new GenericMessage<>(TEST_PAYLOAD)); ResetContext<Object> messageThree = asResetContext(new GenericResetContext<>(TEST_PAYLOAD)); Map<String, Object> metaDataMap = Collections.singletonMap("key", "value"); ResetContext<Object> messageFour = new GenericResetContext<>(TEST_PAYLOAD, metaDataMap); MetaData metaData = MetaData.from(metaDataMap); ResetContext<Object> messageFive = new GenericResetContext<>(TEST_PAYLOAD, metaData); assertSame(MetaData.emptyInstance(), messageOne.getMetaData()); assertEquals(Object.class, messageOne.getPayload().getClass()); assertEquals(Object.class, messageOne.getPayloadType()); assertSame(MetaData.emptyInstance(), messageTwo.getMetaData()); assertEquals(Object.class, messageTwo.getPayload().getClass()); assertEquals(Object.class, messageTwo.getPayloadType()); assertSame(MetaData.emptyInstance(), messageThree.getMetaData()); assertEquals(Object.class, messageThree.getPayload().getClass()); assertEquals(Object.class, messageThree.getPayloadType()); assertNotSame(metaDataMap, messageFour.getMetaData()); assertEquals(metaDataMap, messageFour.getMetaData()); assertEquals(Object.class, messageFour.getPayload().getClass()); assertEquals(Object.class, messageFour.getPayloadType()); assertSame(metaData, messageFive.getMetaData()); assertEquals(Object.class, messageFive.getPayload().getClass()); assertEquals(Object.class, messageFive.getPayloadType()); assertNotEquals(messageOne.getIdentifier(), messageFour.getIdentifier()); assertNotEquals(messageFour.getIdentifier(), messageFive.getIdentifier()); assertNotEquals(messageFive.getIdentifier(), messageOne.getIdentifier()); }
@SuppressWarnings("unchecked") public static <T> ResetContext<T> asResetContext(Object messageOrPayload) { if (messageOrPayload instanceof ResetContext) { return (ResetContext<T>) messageOrPayload; } else if (messageOrPayload instanceof Message) { return new GenericResetContext<>((Message<T>) messageOrPayload); } return new GenericResetContext<>((T) messageOrPayload); }
GenericResetContext extends MessageDecorator<T> implements ResetContext<T> { @SuppressWarnings("unchecked") public static <T> ResetContext<T> asResetContext(Object messageOrPayload) { if (messageOrPayload instanceof ResetContext) { return (ResetContext<T>) messageOrPayload; } else if (messageOrPayload instanceof Message) { return new GenericResetContext<>((Message<T>) messageOrPayload); } return new GenericResetContext<>((T) messageOrPayload); } }
GenericResetContext extends MessageDecorator<T> implements ResetContext<T> { @SuppressWarnings("unchecked") public static <T> ResetContext<T> asResetContext(Object messageOrPayload) { if (messageOrPayload instanceof ResetContext) { return (ResetContext<T>) messageOrPayload; } else if (messageOrPayload instanceof Message) { return new GenericResetContext<>((Message<T>) messageOrPayload); } return new GenericResetContext<>((T) messageOrPayload); } GenericResetContext(T payload);  GenericResetContext(T payload, Map<String, ?> metaData);  GenericResetContext(Message<T> message); }
GenericResetContext extends MessageDecorator<T> implements ResetContext<T> { @SuppressWarnings("unchecked") public static <T> ResetContext<T> asResetContext(Object messageOrPayload) { if (messageOrPayload instanceof ResetContext) { return (ResetContext<T>) messageOrPayload; } else if (messageOrPayload instanceof Message) { return new GenericResetContext<>((Message<T>) messageOrPayload); } return new GenericResetContext<>((T) messageOrPayload); } GenericResetContext(T payload);  GenericResetContext(T payload, Map<String, ?> metaData);  GenericResetContext(Message<T> message); @SuppressWarnings("unchecked") static ResetContext<T> asResetContext(Object messageOrPayload); @Override GenericResetContext<T> withMetaData(Map<String, ?> metaData); @Override GenericResetContext<T> andMetaData(Map<String, ?> additionalMetaData); }
GenericResetContext extends MessageDecorator<T> implements ResetContext<T> { @SuppressWarnings("unchecked") public static <T> ResetContext<T> asResetContext(Object messageOrPayload) { if (messageOrPayload instanceof ResetContext) { return (ResetContext<T>) messageOrPayload; } else if (messageOrPayload instanceof Message) { return new GenericResetContext<>((Message<T>) messageOrPayload); } return new GenericResetContext<>((T) messageOrPayload); } GenericResetContext(T payload);  GenericResetContext(T payload, Map<String, ?> metaData);  GenericResetContext(Message<T> message); @SuppressWarnings("unchecked") static ResetContext<T> asResetContext(Object messageOrPayload); @Override GenericResetContext<T> withMetaData(Map<String, ?> metaData); @Override GenericResetContext<T> andMetaData(Map<String, ?> additionalMetaData);  }