Class StatusMessageSerializer
java.lang.Object
de.iip_ecosphere.platform.transport.status.StatusMessageSerializer
- All Implemented Interfaces:
InputTypeTranslator<byte[],,StatusMessage> OutputTypeTranslator<StatusMessage,,byte[]> Serializer<StatusMessage>,TypeTranslator<StatusMessage,byte[]>
A simple, generic status serializer. Additional enum constants must be registered here.
- Author:
- Holger Eichelberger, SSE
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map<String, ActionType> private static final Map<String, ComponentType> private static final de.iip_ecosphere.platform.support.json.Json -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone(StatusMessage origin) Creates a new value instance and copies the values fromoriginto the new instance.static TypeTranslator<StatusMessage, 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").getType()The type to be handled by this serializer.private static <T> voidDoes the registration ofclsas enum constant and modifiesmappingas side effect.static voidregisterActions(Class<? extends ActionType> type) Registers custom action types.static voidregisterComponents(Class<? extends ComponentType> type) Registers custom component types.byte[]to(StatusMessage source) Translates a source value into a target value ("output to external").
-
Field Details
-
ACTION_CONSTANTS
-
COMPONENT_CONSTANTS
-
MAPPER
private static final de.iip_ecosphere.platform.support.json.Json MAPPER
-
-
Constructor Details
-
StatusMessageSerializer
public StatusMessageSerializer()
-
-
Method Details
-
createTypeTranslator
Creates a type translator based on the serialization approach in this class.- Returns:
- the type translator
-
registerActions
Registers custom action types. Already registered types will not be overridden. Registration follows enum constant conventions, i.e., only static final public values of the given type declared in that type will be considered.- Parameters:
type- the type to register
-
registerComponents
Registers custom component types. Already registered types will not be overridden. Registration follows enum constant conventions, i.e., only static final public values of the given type declared in that type will be considered.- Parameters:
type- the type to register
-
register
Does the registration ofclsas enum constant and modifiesmappingas side effect.- Type Parameters:
T- the "enum" type- Parameters:
cls- the typemapping- the mapping to be modified as side effect
-
from
Description copied from interface:InputTypeTranslatorDeserializes a target value into a source value ("input from external").- Specified by:
fromin interfaceInputTypeTranslator<byte[],StatusMessage> - 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<StatusMessage,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<StatusMessage>- 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<StatusMessage>- Returns:
- the type
-