Package cz.o2.proxima.core.scheme
Interface ValueSerializer<T>
-
- All Superinterfaces:
java.io.Serializable
@Stable public interface ValueSerializer<T> extends java.io.Serializable
A serializer of values with specified scheme.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
ValueSerializer.InitializedWithRepository
When aValueSerializer
needs to be initialized withRepository
instance after the Repository has need created and initialized, it can implement this interface.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.lang.String
asJsonValue(T value)
Convert given value to JSON representation (including quotation).java.util.Optional<T>
deserialize(byte[] input)
Deserialize the bytes to materialized typed message.default T
fromJsonValue(java.lang.String json)
Convert given JSON string to parsed object.T
getDefault()
Retrieve a default value for the type.default java.lang.String
getLogString(T value)
Create a (preferably single line) String representation of the value suitable for logging.default <V> AttributeValueAccessor<T,V>
getValueAccessor()
ProvideAttributeValueAccessor
for give attribute value.default SchemaDescriptors.SchemaTypeDescriptor<T>
getValueSchemaDescriptor()
ProvideSchemaDescriptors.SchemaTypeDescriptor
for given attribute value.default boolean
isUsable()
Check if given serializer can be used without exceptions.default boolean
isValid(byte[] input)
Check if given input is valid by trying to parse it.byte[]
serialize(T value)
Serialize value to bytes.
-
-
-
Method Detail
-
deserialize
java.util.Optional<T> deserialize(byte[] input)
Deserialize the bytes to materialized typed message. If the deserialization fails the returned value is empty.- Parameters:
input
- the serialized data- Returns:
- optional deserialized output
-
serialize
byte[] serialize(T value)
Serialize value to bytes.- Parameters:
value
- the deserialized value- Returns:
- serialized bytes
-
getDefault
T getDefault()
Retrieve a default value for the type.- Returns:
- default value of the type
-
isUsable
default boolean isUsable()
Check if given serializer can be used without exceptions.- Returns:
- true if serializer is usable
-
isValid
default boolean isValid(byte[] input)
Check if given input is valid by trying to parse it.- Parameters:
input
- serialized data- Returns:
true
if this is valid byte representation
-
asJsonValue
default java.lang.String asJsonValue(T value)
Convert given value to JSON representation (including quotation).- Parameters:
value
- the value to encode- Returns:
- the JSON string
-
fromJsonValue
default T fromJsonValue(java.lang.String json)
Convert given JSON string to parsed object.- Parameters:
json
- the JSON representation- Returns:
- parsed object
-
getLogString
default java.lang.String getLogString(T value)
Create a (preferably single line) String representation of the value suitable for logging.- Parameters:
value
- the value to log Convert value toString
suitable for logging.- Returns:
- a String representation suitable for logging
-
getValueSchemaDescriptor
default SchemaDescriptors.SchemaTypeDescriptor<T> getValueSchemaDescriptor()
ProvideSchemaDescriptors.SchemaTypeDescriptor
for given attribute value.- Returns:
- value descriptor
-
getValueAccessor
default <V> AttributeValueAccessor<T,V> getValueAccessor()
ProvideAttributeValueAccessor
for give attribute value.- Returns:
- value accessor
-
-