Package org.javers.core.json
Class BasicStringTypeAdapter<T>
java.lang.Object
org.javers.core.json.JsonTypeAdapterTemplate<T>
org.javers.core.json.BasicStringTypeAdapter<T>
- All Implemented Interfaces:
AbstractJsonTypeAdapter,JsonTypeAdapter<T>
Convenient abstract implementation of
JsonTypeAdapter.
Extend it if you need to represent your ValueType as a single String.
For a concrete adapter implementation example see LocalDateTimeTypeAdapter.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Tdeserialize(String serializedValue) Example deserialization for LocalDateTime:fromJson(com.google.gson.JsonElement json, com.google.gson.JsonDeserializationContext jsonDeserializationContext) abstract StringExample serialization for LocalDateTime:com.google.gson.JsonElementMethods inherited from class org.javers.core.json.JsonTypeAdapterTemplate
getValueType, getValueTypes
-
Constructor Details
-
BasicStringTypeAdapter
public BasicStringTypeAdapter()
-
-
Method Details
-
serialize
Example serialization for LocalDateTime:public String serialize(LocalDateTime sourceValue) { return ISO_DATE_TIME_FORMATTER.print(sourceValue); }- Parameters:
sourceValue- not null
-
deserialize
Example deserialization for LocalDateTime:public LocalDateTime deserialize(String serializedValue) { return ISO_DATE_TIME_FORMATTER.parseLocalDateTime(serializedValue); }- Parameters:
serializedValue- not null
-
fromJson
public T fromJson(com.google.gson.JsonElement json, com.google.gson.JsonDeserializationContext jsonDeserializationContext) - Parameters:
json- not null and not JsonNulljsonDeserializationContext- use it to invoke default deserialization on the specified object
-
toJson
public com.google.gson.JsonElement toJson(T sourceValue, com.google.gson.JsonSerializationContext jsonSerializationContext) - Parameters:
sourceValue- not nulljsonSerializationContext- use it to invoke default serialization on the specified object
-