Class TraceRecordSerializer
java.lang.Object
de.iip_ecosphere.platform.transport.status.TraceRecordSerializer
- All Implemented Interfaces:
InputTypeTranslator<byte[],,TraceRecord> OutputTypeTranslator<TraceRecord,,byte[]> Serializer<TraceRecord>,TypeTranslator<TraceRecord,byte[]>
A simple, generic JSON status serializer. Additional enum constants must be registered here.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClears all ignored types and fields.clone(TraceRecord origin) Creates a new value instance and copies the values fromoriginto the new instance.private static de.iip_ecosphere.platform.support.json.JsonCreates a specific object mapper that allows for lazy default serialization of unknown types as it is the case for the payload inTraceRecord.static TypeTranslator<TraceRecord, String> Creates a type translator based on the serialization approach in this class.from(byte[] data) Deserializes a target value into a source value ("input from external").static TraceRecordFilterReturns the trace record filter.getType()The type to be handled by this serializer.static voidignoreClass(Class<?> cls) Registers a type to be ignored when serializing trace record (payloads).static voidignoreField(Class<?> cls, String field) Registers a field to be ignored when serializing trace record (payloads).static voidignoreFields(Class<?> cls, String... fields) Registers fields to be ignored when serializing trace record (payloads).byte[]to(TraceRecord source) Translates a source value into a target value ("output to external").
-
Field Details
-
ignore
-
filter
-
-
Constructor Details
-
TraceRecordSerializer
public TraceRecordSerializer()
-
-
Method Details
-
getFilter
Returns the trace record filter.- Returns:
- the filter
-
createMapper
private static de.iip_ecosphere.platform.support.json.Json createMapper()Creates a specific object mapper that allows for lazy default serialization of unknown types as it is the case for the payload inTraceRecord.- Returns:
- the object mapper
-
createTypeTranslator
Creates a type translator based on the serialization approach in this class.- Returns:
- the type translator
-
from
Description copied from interface:InputTypeTranslatorDeserializes a target value into a source value ("input from external").- Specified by:
fromin interfaceInputTypeTranslator<byte[],TraceRecord> - Parameters:
data- the data to be translated back- Returns:
- the serialized object
- Throws:
IOException- in case that serialization fails
-
to
Description copied from interface:OutputTypeTranslatorTranslates a source value into a target value ("output to external").- Specified by:
toin interfaceOutputTypeTranslator<TraceRecord,byte[]> - Parameters:
source- the source value to be translated- Returns:
- the target value
- Throws:
IOException- in case that translation fails
-
clone
Description copied from interface:SerializerCreates a new value instance and copies the values fromoriginto the new instance. Use theSerializerRegistryto implement cloning of nested object values.- Specified by:
clonein interfaceSerializer<TraceRecord>- Parameters:
origin- the object to clone- Returns:
- the cloned object
- Throws:
IOException- in case that cloning/serialization operations fail
-
getType
Description copied from interface:SerializerThe type to be handled by this serializer.- Specified by:
getTypein interfaceSerializer<TraceRecord>- Returns:
- the type
-
ignoreClass
Registers a type to be ignored when serializing trace record (payloads).- Parameters:
cls- the class representing the type to be ignored
-
ignoreField
Registers a field to be ignored when serializing trace record (payloads).- Parameters:
cls- the class representing the type containing the fieldfield- the field to be ignored
-
ignoreFields
Registers fields to be ignored when serializing trace record (payloads).- Parameters:
cls- the class representing the type containing the fieldfields- the fields to be ignored- See Also:
-
clearIgnores
public static void clearIgnores()Clears all ignored types and fields.
-