@SuppressWarnings("unchecked") @Override public <R> SerializedObject<R> serializeMetaData( Serializer serializer, Class<R> expectedRepresentation) { if (serializer.equals(serializedMetaData.getSerializer())) { final SerializedObject serializedObject = serializedMetaData.getSerializedObject(); return CONVERTER_FACTORY .getConverter(serializedObject.getContentType(), expectedRepresentation) .convert(serializedObject); } return serializer.serialize(serializedMetaData.getObject(), expectedRepresentation); }
@SuppressWarnings("EqualsBetweenInconvertibleTypes") @Override public SerializedMessage<T> withMetaData(Map<String, ?> metaData) { if (serializedMetaData.getObject().equals(metaData)) { return this; } return new SerializedMessage<>(this, metaData); }
/** * Indicates whether the payload of this message has already been deserialized. * * @return <code>true</code> if the payload is deserialized, otherwise <code>false</code> */ public boolean isPayloadDeserialized() { return serializedPayload.isDeserialized(); }
@Override public Class<T> getPayloadType() { return serializedPayload.getType(); }
@Override public T getPayload() { return serializedPayload.getObject(); }
@Override public MetaData getMetaData() { MetaData metaData = serializedMetaData.getObject(); return metaData == null ? MetaData.emptyInstance() : metaData; }