/** * Initialize the response message with given {@code result} and {@code metaData}. * * @param result The result reported by the Query Handler, may not be {@code null} * @param metaData The meta data to contain in the message */ public GenericQueryResponseMessage(R result, Map<String, ?> metaData) { super(new GenericMessage<>(result, metaData)); }
/** * Constructs a Message for the given {@code payload} and {@code meta data}. The given {@code metaData} is * merged with the MetaData from the correlation data of the current unit of work, if present. * In case the {@code payload == null}, {@link Void} will be used as the {@code payloadType}. * * @param payload The payload for the message as a generic {@code T} * @param metaData The meta data {@link Map} for the message */ @SuppressWarnings("unchecked") public GenericMessage(T payload, Map<String, ?> metaData) { this(getDeclaredPayloadType(payload), payload, metaData); }
private GenericMessage(GenericMessage<T> original, MetaData metaData) { super(original.getIdentifier()); this.payload = original.getPayload(); this.payloadType = original.getPayloadType(); this.metaData = metaData; }
@Override public <R> SerializedObject<R> serializeMetaData(Serializer serializer, Class<R> expectedRepresentation) { return serializedObjectHolder().serializeMetaData(serializer, expectedRepresentation); }
@Override public <R> SerializedObject<R> serializePayload(Serializer serializer, Class<R> expectedRepresentation) { return serializedObjectHolder().serializePayload(serializer, expectedRepresentation); }
/** * Initialize the response message with a specific {@code declaredResultType}, the given {@code result} as payload * and {@code metaData}. * * @param declaredResultType A {@link java.lang.Class} denoting the declared result type of this query response * message * @param result The result reported by the Query Handler, may be {@code null} * @param metaData The meta data to contain in the message */ public GenericQueryResponseMessage(Class<R> declaredResultType, R result, Map<String, ?> metaData) { super(new GenericMessage<>(declaredResultType, result, metaData)); }
private GenericMessage(GenericMessage<T> original, MetaData metaData) { super(original.getIdentifier()); this.payload = original.getPayload(); this.payloadType = original.getPayloadType(); this.metaData = metaData; }
/** * Constructor to reconstruct a Message using existing data. Note that no correlation data * from a UnitOfWork is attached when using this constructor. If you're constructing a new * Message, use {@link #GenericMessage(Object, Map)} instead. * * @param identifier The identifier of the Message * @param payload The payload of the message * @param metaData The meta data of the message * @throws NullPointerException when the given {@code payload} is {@code null}. */ @SuppressWarnings("unchecked") public GenericMessage(String identifier, T payload, Map<String, ?> metaData) { this(identifier, getDeclaredPayloadType(payload), payload, metaData); }
@Override public <R> SerializedObject<R> serializeMetaData(Serializer serializer, Class<R> expectedRepresentation) { return serializedObjectHolder().serializeMetaData(serializer, expectedRepresentation); }
/** * Initializes {@link GenericSubscriptionQueryUpdateMessage} with incremental update of provided {@code * declaredType} and {@code metaData}. * * @param declaredType the type of the update * @param payload the payload of the update * @param metaData the metadata of the update */ public GenericSubscriptionQueryUpdateMessage(Class<U> declaredType, U payload, Map<String, ?> metaData) { super(new GenericMessage<>(declaredType, payload, metaData)); }
private GenericMessage(GenericMessage<T> original, MetaData metaData) { super(original.getIdentifier()); this.payload = original.getPayload(); this.payloadType = original.getPayloadType(); this.metaData = metaData; }
/** * Constructs a Message for the given {@code payload} and {@code meta data}. The given {@code metaData} is * merged with the MetaData from the correlation data of the current unit of work, if present. * In case the {@code payload == null}, {@link Void} will be used as the {@code payloadType}. * * @param payload The payload for the message as a generic {@code T} * @param metaData The meta data {@link Map} for the message */ @SuppressWarnings("unchecked") public GenericMessage(T payload, Map<String, ?> metaData) { this(getDeclaredPayloadType(payload), payload, metaData); }
@Override public <R> SerializedObject<R> serializePayload(Serializer serializer, Class<R> expectedRepresentation) { return serializedObjectHolder().serializePayload(serializer, expectedRepresentation); }
/** * Constructor to reconstruct an EventMessage using existing data. * * @param identifier The identifier of the Message * @param timestamp The timestamp of the Message creation * @param payload The payload of the message * @param metaData The meta data of the message */ public GenericEventMessage(String identifier, T payload, Map<String, ?> metaData, Instant timestamp) { this(new GenericMessage<>(identifier, payload, metaData), timestamp); }
/** * Constructs a Message for the given {@code payload} and {@code meta data}. The given {@code metaData} is * merged with the MetaData from the correlation data of the current unit of work, if present. * In case the {@code payload == null}, {@link Void} will be used as the {@code payloadType}. * * @param payload The payload for the message as a generic {@code T} * @param metaData The meta data {@link Map} for the message */ @SuppressWarnings("unchecked") public GenericMessage(T payload, Map<String, ?> metaData) { this(getDeclaredPayloadType(payload), payload, metaData); }
/** * Creates a ResultMessage with the given {@code exception} and {@code metaData}. * * @param exception the Exception describing the cause of an error * @param metaData the meta data for the Message */ public GenericResultMessage(Throwable exception, Map<String, ?> metaData) { this(new GenericMessage<>(null, metaData), exception); }
/** * Constructor to reconstruct a Message using existing data. Note that no correlation data * from a UnitOfWork is attached when using this constructor. If you're constructing a new * Message, use {@link #GenericMessage(Object, Map)} instead. * * @param identifier The identifier of the Message * @param payload The payload of the message * @param metaData The meta data of the message * @throws NullPointerException when the given {@code payload} is {@code null}. */ @SuppressWarnings("unchecked") public GenericMessage(String identifier, T payload, Map<String, ?> metaData) { this(identifier, getDeclaredPayloadType(payload), payload, metaData); }
/** * Creates a ResultMessage with the given {@code result} as the payload and {@code metaData} as the meta data. * * @param result the payload for the Message * @param metaData the meta data for the Message */ public GenericResultMessage(R result, Map<String, ?> metaData) { this(new GenericMessage<>(result, metaData)); }
/** * Constructor to reconstruct a Message using existing data. Note that no correlation data * from a UnitOfWork is attached when using this constructor. If you're constructing a new * Message, use {@link #GenericMessage(Object, Map)} instead. * * @param identifier The identifier of the Message * @param payload The payload of the message * @param metaData The meta data of the message * @throws NullPointerException when the given {@code payload} is {@code null}. */ @SuppressWarnings("unchecked") public GenericMessage(String identifier, T payload, Map<String, ?> metaData) { this(identifier, getDeclaredPayloadType(payload), payload, metaData); }
/** * Initialize the response message with given {@code declaredResultType}, {@code exception} and {@code metaData}. * * @param declaredResultType The declared type of the Query Response Message to be created * @param exception The Exception describing the cause of an error * @param metaData The meta data to contain in the message */ public GenericQueryResponseMessage(Class<R> declaredResultType, Throwable exception, Map<String, ?> metaData) { super(new GenericMessage<>(declaredResultType, null, metaData), exception); }