@Override public Converter getConverter() { return delegate.getConverter(); } }
@Override public <T> IntermediateEventRepresentation upcast(SerializedType outputType, Class<T> expectedRepresentationType, Function<T, T> upcastFunction, Function<MetaData, MetaData> metaDataUpcastFunction) { return new UpcastedEventRepresentation<>(outputType, this, upcastFunction, metaDataUpcastFunction, expectedRepresentationType, serializer.getConverter()); }
@Override @SuppressWarnings("unchecked") public <D> SerializedObject<D> getData(Class<D> requiredType) { return serializer.getConverter().convert(data, requiredType); }
/** * Indicates whether the given {@code desiredFormat} is supported as a representation for this type. More * specifically, it will consult the serializer that returned this instance whether it has a converter to convert * the serialized object's data to the desired type * * @param desiredFormat the format in which the serialized object is desired * @param <T> the format in which the serialized object is desired * @return {@code true} if the format is supported, otherwise {@code false} */ public <T> boolean supportsFormat(Class<T> desiredFormat) { return serializer.getConverter().canConvert(serializedObject.getContentType(), desiredFormat); }
/** * Returns the data contained in the serialized object in the given {@code desiredFormat}, if supported. If the * desired format is unsupported, an exception is thrown, depending on the serializer. * <p> * To verify whether a format is supported, use {@link #supportsFormat(Class)}. * * @param desiredFormat the format in which the data is desired * @param <T> the format in which the data is desired * @return the data in the desired format */ public <T> T readData(Class<T> desiredFormat) { return serializer.getConverter().convert(serializedObject, desiredFormat).getData(); }
@SuppressWarnings("unchecked") public <T> SerializedObject<T> serializeMetaData(Serializer serializer, Class<T> expectedRepresentation) { synchronized (metaDataGuard) { SerializedObject existingForm = serializedMetaData.get(serializer); if (existingForm == null) { SerializedObject<T> serialized = serializer.serialize(message.getMetaData(), expectedRepresentation); serializedMetaData.put(serializer, serialized); return serialized; } else { return serializer.getConverter().convert(existingForm, expectedRepresentation); } } } }
@SuppressWarnings("unchecked") @Override public <R> SerializedObject<R> serializePayload(Serializer serializer, Class<R> expectedRepresentation) { if (serializer.equals(payload.getSerializer())) { return serializer.getConverter().convert(payload.getSerializedObject(), expectedRepresentation); } return serializer.serialize(payload.getObject(), expectedRepresentation); }
@SuppressWarnings("unchecked") @Override public <R> SerializedObject<R> serializeMetaData(Serializer serializer, Class<R> expectedRepresentation) { if (serializer.equals(metaData.getSerializer())) { return serializer.getConverter().convert(metaData.getSerializedObject(), expectedRepresentation); } return serializer.serialize(metaData.getObject(), expectedRepresentation); }
@SuppressWarnings("unchecked") public <T> SerializedObject<T> serializePayload(Serializer serializer, Class<T> expectedRepresentation) { synchronized (payloadGuard) { SerializedObject existingForm = serializedPayload.get(serializer); if (existingForm == null) { SerializedObject<T> serialized = serializer.serialize(message.getPayload(), expectedRepresentation); if (message.getPayload() == null) { // make sure the payload type is maintained serialized = new SimpleSerializedObject<>(serialized.getData(), serialized.getContentType(), serializer.typeForClass(message.getPayloadType())); } serializedPayload.put(serializer, serialized); return serialized; } else { return serializer.getConverter().convert(existingForm, expectedRepresentation); } } }
@Override public Converter getConverter() { return serializer.getConverter(); } }
@Override public Converter getConverter() { return delegate.getConverter(); } }
@Override public <T> IntermediateEventRepresentation upcast(SerializedType outputType, Class<T> expectedRepresentationType, Function<T, T> upcastFunction, Function<MetaData, MetaData> metaDataUpcastFunction) { return new UpcastedEventRepresentation<>(outputType, this, upcastFunction, metaDataUpcastFunction, expectedRepresentationType, serializer.getConverter()); }
@Override @SuppressWarnings("unchecked") public <D> SerializedObject<D> getData(Class<D> requiredType) { return serializer.getConverter().convert(data, requiredType); }
@Override @SuppressWarnings("unchecked") public <D> SerializedObject<D> getData(Class<D> requiredType) { return serializer.getConverter().convert(data, requiredType); }
@Override public <T> IntermediateEventRepresentation upcast(SerializedType outputType, Class<T> expectedRepresentationType, Function<T, T> upcastFunction, Function<MetaData, MetaData> metaDataUpcastFunction) { return new UpcastedEventRepresentation<>(outputType, this, upcastFunction, metaDataUpcastFunction, expectedRepresentationType, serializer.getConverter()); }
/** * Indicates whether the given {@code desiredFormat} is supported as a representation for this type. More * specifically, it will consult the serializer that returned this instance whether it has a converter to convert * the serialized object's data to the desired type * * @param desiredFormat the format in which the serialized object is desired * @param <T> the format in which the serialized object is desired * @return {@code true} if the format is supported, otherwise {@code false} */ public <T> boolean supportsFormat(Class<T> desiredFormat) { return serializer.getConverter().canConvert(serializedObject.getContentType(), desiredFormat); }
@SuppressWarnings("unchecked") @Override public <R> SerializedObject<R> serializeMetaData(Serializer serializer, Class<R> expectedRepresentation) { if (serializer.equals(metaData.getSerializer())) { return serializer.getConverter().convert(metaData.getSerializedObject(), expectedRepresentation); } return serializer.serialize(metaData.getObject(), expectedRepresentation); }
@SuppressWarnings("unchecked") @Override public <R> SerializedObject<R> serializePayload(Serializer serializer, Class<R> expectedRepresentation) { if (serializer.equals(payload.getSerializer())) { return serializer.getConverter().convert(payload.getSerializedObject(), expectedRepresentation); } return serializer.serialize(payload.getObject(), expectedRepresentation); }
@SuppressWarnings("unchecked") @Override public <R> SerializedObject<R> serializeMetaData(Serializer serializer, Class<R> expectedRepresentation) { if (serializer.equals(metaData.getSerializer())) { return serializer.getConverter().convert(metaData.getSerializedObject(), expectedRepresentation); } return serializer.serialize(metaData.getObject(), expectedRepresentation); }
@SuppressWarnings("unchecked") @Override public <R> SerializedObject<R> serializePayload(Serializer serializer, Class<R> expectedRepresentation) { if (serializer.equals(payload.getSerializer())) { return serializer.getConverter().convert(payload.getSerializedObject(), expectedRepresentation); } return serializer.serialize(payload.getObject(), expectedRepresentation); }