@Test void testAndMetaData() { Object payload = new Object(); Map<String, Object> metaDataMap = Collections.singletonMap("key", "value"); MetaData metaData = MetaData.from(metaDataMap); GenericEventMessage<Object> message = new GenericEventMessage<>(payload, metaData); GenericEventMessage<Object> message1 = message.andMetaData(MetaData.emptyInstance()); GenericEventMessage<Object> message2 = message.andMetaData( MetaData.from(Collections.singletonMap("key", "otherValue"))); assertEquals(1, message1.getMetaData().size()); assertEquals("value", message1.getMetaData().get("key")); assertEquals(1, message2.getMetaData().size()); assertEquals("otherValue", message2.getMetaData().get("key")); }
@Override public GenericEventMessage<T> andMetaData(Map<String, ?> metaData) { if (metaData == null || metaData.isEmpty() || getMetaData().equals(metaData)) { return this; } return new GenericEventMessage<>(getDelegate().andMetaData(metaData), timestampSupplier); }
GenericEventMessage extends MessageDecorator<T> implements EventMessage<T> { @Override public GenericEventMessage<T> andMetaData(Map<String, ?> metaData) { if (metaData == null || metaData.isEmpty() || getMetaData().equals(metaData)) { return this; } return new GenericEventMessage<>(getDelegate().andMetaData(metaData), timestampSupplier); } }
GenericEventMessage extends MessageDecorator<T> implements EventMessage<T> { @Override public GenericEventMessage<T> andMetaData(Map<String, ?> metaData) { if (metaData == null || metaData.isEmpty() || getMetaData().equals(metaData)) { return this; } return new GenericEventMessage<>(getDelegate().andMetaData(metaData), timestampSupplier); } GenericEventMessage(T payload);  GenericEventMessage(T payload, Map<String, ?> metaData);  GenericEventMessage(String identifier, T payload, Map<String, ?> metaData, Instant timestamp);  GenericEventMessage(Message<T> delegate, Supplier<Instant> timestampSupplier); protected  GenericEventMessage(Message<T> delegate, Instant timestamp); }
GenericEventMessage extends MessageDecorator<T> implements EventMessage<T> { @Override public GenericEventMessage<T> andMetaData(Map<String, ?> metaData) { if (metaData == null || metaData.isEmpty() || getMetaData().equals(metaData)) { return this; } return new GenericEventMessage<>(getDelegate().andMetaData(metaData), timestampSupplier); } GenericEventMessage(T payload);  GenericEventMessage(T payload, Map<String, ?> metaData);  GenericEventMessage(String identifier, T payload, Map<String, ?> metaData, Instant timestamp);  GenericEventMessage(Message<T> delegate, Supplier<Instant> timestampSupplier); protected  GenericEventMessage(Message<T> delegate, Instant timestamp); @SuppressWarnings("unchecked") static EventMessage<T> asEventMessage(Object event); @Override Instant getTimestamp(); @Override GenericEventMessage<T> withMetaData(Map<String, ?> metaData); @Override GenericEventMessage<T> andMetaData(Map<String, ?> metaData); }
GenericEventMessage extends MessageDecorator<T> implements EventMessage<T> { @Override public GenericEventMessage<T> andMetaData(Map<String, ?> metaData) { if (metaData == null || metaData.isEmpty() || getMetaData().equals(metaData)) { return this; } return new GenericEventMessage<>(getDelegate().andMetaData(metaData), timestampSupplier); } GenericEventMessage(T payload);  GenericEventMessage(T payload, Map<String, ?> metaData);  GenericEventMessage(String identifier, T payload, Map<String, ?> metaData, Instant timestamp);  GenericEventMessage(Message<T> delegate, Supplier<Instant> timestampSupplier); protected  GenericEventMessage(Message<T> delegate, Instant timestamp); @SuppressWarnings("unchecked") static EventMessage<T> asEventMessage(Object event); @Override Instant getTimestamp(); @Override GenericEventMessage<T> withMetaData(Map<String, ?> metaData); @Override GenericEventMessage<T> andMetaData(Map<String, ?> metaData); static Clock clock; }