public class BaseDataTypeSerializer extends JavaTypeSerializer<BaseDataType>
BaseDataType
instances.BIGDECIMAL_SERIALIZER, BIGINTEGER_SERIALIZER, BOOLEAN_SERIALIZER, BYTEARRAY_SERIALIZER, DOUBLE_SERIALIZER, FLOAT_SERIALIZER, INTEGER_SERIALIZER, LONG_SERIALIZER, mapper, SHORT_SERIALIZER, STRING_SERIALIZER
Constructor and Description |
---|
BaseDataTypeSerializer()
Create a new serializer for
BaseDataType instances. |
Modifier and Type | Method and Description |
---|---|
BaseDataType |
fromJson(BaseDataType arg,
java.lang.String sval)
Parse the string JSON representation and assign it to the given argument.
|
private JavaTypeSerializer |
getBaseSerializer(java.lang.String typeName)
Get the dedicated serializer for the specified
BaseDataType implementation, which will be used
to convert the JSON text to a Java instance, to which the BaseDataType instance will be
assigned. |
BaseDataType |
initialize(java.lang.Class<? extends BaseDataType> definitionType)
Create an initial (default) instance for this serializer.
|
com.fasterxml.jackson.databind.JsonNode |
toJson(BaseDataType val)
Serialize the given instance to JSON.
|
fromJson, getSerializer, getSerializer, getType, newInstance, newRecord, readArray, readArray, readArray, readMap, resolveJavaType, toJsonArray, toJsonObject
public BaseDataTypeSerializer()
BaseDataType
instances.public BaseDataType initialize(java.lang.Class<? extends BaseDataType> definitionType) throws java.lang.InstantiationException, java.lang.IllegalAccessException
Can be null for non-mutable instances.
initialize
in class JavaTypeSerializer<BaseDataType>
definitionType
- The type as it appears at the parameter's definition.null
for immutable types, a Java native value for native types or a new instance,
for mutable types.java.lang.InstantiationException
java.lang.IllegalAccessException
public BaseDataType fromJson(BaseDataType arg, java.lang.String sval) throws RequestArgumentError
fromJson
in class JavaTypeSerializer<BaseDataType>
arg
- The argument (obtained via initialize(java.lang.Class<? extends com.goldencode.p2j.util.BaseDataType>)
.sval
- The string JSON representation of this argument.RequestArgumentError
- If the argument can't be parsed.public com.fasterxml.jackson.databind.JsonNode toJson(BaseDataType val)
toJson
in class JavaTypeSerializer<BaseDataType>
val
- The instance to serialize.private JavaTypeSerializer getBaseSerializer(java.lang.String typeName)
BaseDataType
implementation, which will be used
to convert the JSON text to a Java instance, to which the BaseDataType
instance will be
assigned.typeName
- The type name, as returned by BaseDataType.getTypeName()
.null
if the type is not supported.