Package io.fluxcapacitor.proxy
Class ProxySerializer
java.lang.Object
io.fluxcapacitor.proxy.ProxySerializer
- All Implemented Interfaces:
ContentFilter
,Serializer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<V> V
Creates a deep copy of the given object using serialization.<V> V
Converts a given object to another type using the serializer's object mapping rules.<I extends SerializedObject<byte[]>>
Stream<DeserializingObject<byte[], I>> deserialize
(Stream<I> stream, UnknownTypeStrategy unknownTypeStrategy) Upcasts and deserializes a stream of serialized objects.Downcasts aData
object to the specified revision level.Downcasts the given object to a previous revision.<T> T
filterContent
(T t, User user) Filters the given value based on the current viewer (user) context.registerDowncasters
(Object... casterCandidates) Registers one or more downcaster candidates.registerTypeCaster
(String s, String s1) Registers a mapping from an old type identifier to a new one.registerUpcasters
(Object... casterCandidates) Registers one or more upcaster candidates.Data
<byte[]> Serializes the given object into aData
wrapper using the specified format.upcastType
(String s) Returns the upcasted type name for a legacy type identifier.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.fluxcapacitor.javaclient.common.serialization.Serializer
deserialize, deserialize, deserializeMessage, deserializeMessages, deserializeMessages, deserializeMessages, deserializeMessages, registerCasters, serialize
-
Constructor Details
-
ProxySerializer
public ProxySerializer()
-
-
Method Details
-
serialize
Description copied from interface:Serializer
Serializes the given object into aData
wrapper using the specified format.- Specified by:
serialize
in interfaceSerializer
- Parameters:
object
- the object to serializeformat
- the desired serialization format (e.g. \"json\"); may benull
- Returns:
- serialized object as
Data
-
deserialize
public <I extends SerializedObject<byte[]>> Stream<DeserializingObject<byte[],I>> deserialize(Stream<I> stream, UnknownTypeStrategy unknownTypeStrategy) Description copied from interface:Serializer
Upcasts and deserializes a stream of serialized objects. Each result in the output stream contains both a provider for the deserialized object and the serialized object after upcasting that is used as the source of the deserialized object.Deserialization is performed lazily. This means that actual conversion for a given result in the output stream only happens if
DeserializingObject.getPayload()
is invoked on the result. This has the advantage that a caller can inspect what type will be returned viainvalid reference
DeserializingObject#getSerializedObject()
You can specify whether deserialization of a result in the output stream should fail with a
DeserializationException
if a type is unknown (not a class). It is up to the implementation to determine what should happen if a type is unknown but thefailOnUnknownType
flag is false.- Specified by:
deserialize
in interfaceSerializer
- Type Parameters:
I
- the type of the serialized object- Parameters:
stream
- data input stream to deserializeunknownTypeStrategy
- value that determines what to do when encountering unknown types- Returns:
- a stream containing deserialization results
-
convert
Description copied from interface:Serializer
Converts a given object to another type using the serializer's object mapping rules.- Specified by:
convert
in interfaceSerializer
- Type Parameters:
V
- the result type- Parameters:
o
- the input valueaClass
- the target type- Returns:
- the converted value
-
clone
Description copied from interface:Serializer
Creates a deep copy of the given object using serialization.- Specified by:
clone
in interfaceSerializer
- Type Parameters:
V
- the type of the value- Parameters:
o
- the object to clone- Returns:
- a deep copy
-
registerUpcasters
Description copied from interface:Serializer
Registers one or more upcaster candidates.- Specified by:
registerUpcasters
in interfaceSerializer
- Parameters:
casterCandidates
- beans with upcasting logic- Returns:
- a registration handle
-
registerDowncasters
Description copied from interface:Serializer
Registers one or more downcaster candidates.- Specified by:
registerDowncasters
in interfaceSerializer
- Parameters:
casterCandidates
- beans with downcasting logic- Returns:
- a registration handle
-
registerTypeCaster
Description copied from interface:Serializer
Registers a mapping from an old type identifier to a new one.- Specified by:
registerTypeCaster
in interfaceSerializer
- Parameters:
s
- the legacy type names1
- the canonical or updated type name- Returns:
- a registration handle
-
upcastType
Description copied from interface:Serializer
Returns the upcasted type name for a legacy type identifier.- Specified by:
upcastType
in interfaceSerializer
- Parameters:
s
- the original type- Returns:
- the remapped (or unchanged) type name
-
downcast
Description copied from interface:Serializer
Downcasts the given object to a previous revision.- Specified by:
downcast
in interfaceSerializer
- Parameters:
o
- the object to downcasti
- the target revision- Returns:
- a revisioned form of the object
-
downcast
Description copied from interface:Serializer
Downcasts aData
object to the specified revision level.- Specified by:
downcast
in interfaceSerializer
- Parameters:
data
- the serialized datai
- the target revision number- Returns:
- a transformed object matching the older revision
-
filterContent
Description copied from interface:ContentFilter
Filters the given value based on the current viewer (user) context. If aFilterContent
handler exists in the object's class, it will be invoked to produce a user-specific view of the data.- Specified by:
filterContent
in interfaceContentFilter
- Type Parameters:
T
- the type of the content object- Parameters:
t
- the original objectuser
- the user viewing the content- Returns:
- the filtered version of the object, or the original object if filtering failed or was not applicable
-