Class GsonObjectSerializer
java.lang.Object
com.reallifedeveloper.common.infrastructure.GsonObjectSerializer
- All Implemented Interfaces:
ObjectSerializer<String>
An implementation of the
ObjectSerializer
that uses JSON as the serialized form.- Author:
- RealLifeDeveloper
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newGsonObjectSerializer
with default values. -
Method Summary
-
Field Details
-
DATE_FORMAT
The format used to parse and format date objects. The string is a pattern that can be used by ajava.time.DateTimeFormatter
.- See Also:
-
LOCAL_DATE_TIME_FORMAT
The format used to parse and formatjava.time.LocalDateTime
objects. The string is a pattern that can be used by aDateTimeFormatter
.- See Also:
-
DATE_TIME_FORMAT
The format used to parse and formatjava.time.ZonedDateTime
objects. The string is a pattern that can be used by aDateTimeFormatter
.- See Also:
-
-
Constructor Details
-
GsonObjectSerializer
public GsonObjectSerializer()Creates a newGsonObjectSerializer
with default values.The default values include using the pattern "yyyy-MM-dd\'T\'HH:mm:ss.SSSX" when working with
java.time.ZonedDateTime
objects.
-
-
Method Details
-
serialize
Description copied from interface:ObjectSerializer
Converts an object to its serialized form.The implementation should support serializing
null
values.- Specified by:
serialize
in interfaceObjectSerializer<String>
- Parameters:
object
- the object to serialize, can benull
- Returns:
- the serialized representation of
object
-
deserialize
Description copied from interface:ObjectSerializer
Given the serialized representation of an object, converts it back to the object.- Specified by:
deserialize
in interfaceObjectSerializer<String>
- Type Parameters:
U
- the type of the object- Parameters:
serializedObject
- the serialized form of an objectobjectType
- the concrete class of the serialized object- Returns:
- the object represented by
serializedObject
-