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 newGsonObjectSerializerwith 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.LocalDateTimeobjects. The string is a pattern that can be used by aDateTimeFormatter.- See Also:
-
DATE_TIME_FORMAT
The format used to parse and formatjava.time.ZonedDateTimeobjects. The string is a pattern that can be used by aDateTimeFormatter.- See Also:
-
-
Constructor Details
-
GsonObjectSerializer
public GsonObjectSerializer()Creates a newGsonObjectSerializerwith default values.The default values include using the pattern "yyyy-MM-dd\'T\'HH:mm:ss.SSSX" when working with
java.time.ZonedDateTimeobjects.
-
-
Method Details
-
serialize
Description copied from interface:ObjectSerializerConverts an object to its serialized form.The implementation should support serializing
nullvalues.- Specified by:
serializein interfaceObjectSerializer<String>- Parameters:
object- the object to serialize, can benull- Returns:
- the serialized representation of
object
-
deserialize
Description copied from interface:ObjectSerializerGiven the serialized representation of an object, converts it back to the object.- Specified by:
deserializein 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
-