@SuppressWarnings("unchecked") @Override public <S, T> T deserialize(SerializedObject<S> serializedObject) { if (SerializedType.emptyType().equals(serializedObject.getType())) { return null; } if (UnknownSerializedType.class.isAssignableFrom(classForType(serializedObject.getType()))) { return (T) new UnknownSerializedType(this, serializedObject); } return (T) doDeserialize(serializedObject, xStream); }
@Override public <T> SerializedObject<T> serialize(Object object, Class<T> expectedType) { T result = doSerialize(object, expectedType, xStream); return new SimpleSerializedObject<>(result, expectedType, typeForClass(ObjectUtils.nullSafeTypeOf(object))); }
/** * Convert the given {@code source}, of type {@code sourceType} to the given {@code targetType}. * * @param <S> The type of data that needs to be converted * @param <T> The target type of the conversion * @param source The object to convert * @param sourceType The source type of the conversion * @param targetType The target type of the conversion * @return The converted object */ protected <S, T> T convert(S source, Class<S> sourceType, Class<T> targetType) { return getConverter().convert(source, sourceType, targetType); }
@Override public SerializedType typeForClass(Class type) { if (type == null || Void.TYPE.equals(type) || Void.class.equals(type)) { return SimpleSerializedType.emptyType(); } return new SimpleSerializedType(typeIdentifierOf(type), revisionOf(type)); }
/** * Instantiate a {@link AbstractXStreamSerializer} based on the fields contained in the {@link Builder}. * * @param builder the {@link Builder} used to instantiate a {@link AbstractXStreamSerializer} instance */ protected AbstractXStreamSerializer(Builder builder) { builder.validate(); this.charset = builder.charset; this.xStream = builder.xStream; this.converter = builder.converter; this.revisionResolver = builder.revisionResolver; if (converter instanceof ChainingConverter) { registerConverters((ChainingConverter) converter); } xStream.addImmutableType(UUID.class, true); // Message serialization xStream.alias("domain-event", GenericDomainEventMessage.class); xStream.alias("event", GenericEventMessage.class); xStream.alias("command", GenericCommandMessage.class); // For backward compatibility xStream.alias("uuid", UUID.class); xStream.alias("meta-data", MetaData.class); xStream.registerConverter(new MetaDataConverter(xStream.getMapper())); }
@SuppressWarnings("unchecked") @Override public <S, T> T deserialize(SerializedObject<S> serializedObject) { if (SerializedType.emptyType().equals(serializedObject.getType())) { return null; } return (T) doDeserialize(serializedObject, xStream); }
@Override public SerializedType typeForClass(Class type) { if (type == null || Void.TYPE.equals(type) || Void.class.equals(type)) { return SimpleSerializedType.emptyType(); } return new SimpleSerializedType(typeIdentifierOf(type), revisionOf(type)); }
/** * Instantiate a {@link AbstractXStreamSerializer} based on the fields contained in the {@link Builder}. * * @param builder the {@link Builder} used to instantiate a {@link AbstractXStreamSerializer} instance */ protected AbstractXStreamSerializer(Builder builder) { builder.validate(); this.charset = builder.charset; this.xStream = builder.xStream; this.converter = builder.converter; this.revisionResolver = builder.revisionResolver; if (converter instanceof ChainingConverter) { registerConverters((ChainingConverter) converter); } xStream.addImmutableType(UUID.class, true); // Message serialization xStream.alias("domain-event", GenericDomainEventMessage.class); xStream.alias("event", GenericEventMessage.class); xStream.alias("command", GenericCommandMessage.class); // For backward compatibility xStream.alias("uuid", UUID.class); xStream.alias("meta-data", MetaData.class); xStream.registerConverter(new MetaDataConverter(xStream.getMapper())); }
@Override public <T> SerializedObject<T> serialize(Object object, Class<T> expectedType) { T result = doSerialize(object, expectedType, xStream); return new SimpleSerializedObject<>(result, expectedType, typeForClass(ObjectUtils.nullSafeTypeOf(object))); }
@Override public SerializedType typeForClass(Class type) { if (type == null || Void.TYPE.equals(type) || Void.class.equals(type)) { return SimpleSerializedType.emptyType(); } return new SimpleSerializedType(typeIdentifierOf(type), revisionOf(type)); }
@SuppressWarnings("unchecked") @Override public <S, T> T deserialize(SerializedObject<S> serializedObject) { if (SerializedType.emptyType().equals(serializedObject.getType())) { return null; } if (UnknownSerializedType.class.isAssignableFrom(classForType(serializedObject.getType()))) { return (T) new UnknownSerializedType(this, serializedObject); } return (T) doDeserialize(serializedObject, xStream); }
/** * Convert the given {@code source}, of type {@code sourceType} to the given {@code targetType}. * * @param <S> The type of data that needs to be converted * @param <T> The target type of the conversion * @param source The object to convert * @param sourceType The source type of the conversion * @param targetType The target type of the conversion * @return The converted object */ protected <S, T> T convert(S source, Class<S> sourceType, Class<T> targetType) { return getConverter().convert(source, sourceType, targetType); }
this.revisionResolver = revisionResolver; if (converter instanceof ChainingConverter) { registerConverters((ChainingConverter) converter);
@Override public <T> SerializedObject<T> serialize(Object object, Class<T> expectedType) { T result = doSerialize(object, expectedType, xStream); return new SimpleSerializedObject<>(result, expectedType, typeForClass(ObjectUtils.nullSafeTypeOf(object))); }
/** * Convert the given {@code source}, of type {@code sourceType} to the given {@code targetType}. * * @param <S> The type of data that needs to be converted * @param <T> The target type of the conversion * @param source The object to convert * @param sourceType The source type of the conversion * @param targetType The target type of the conversion * @return The converted object */ protected <S, T> T convert(S source, Class<S> sourceType, Class<T> targetType) { return getConverter().convert(source, sourceType, targetType); }