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:
JsonTypeAdapter<T>
public abstract class BasicStringTypeAdapter<T> extends JsonTypeAdapterTemplate<T>
Convenient abstract implementation ofJsonTypeAdapter
. Extend it if you need to represent yourValueType
as single String and don't want to deal with Gson API.
Implementation shouldn't take care about nulls (nulls are handled by Gson engine)
For concrete class example seeorg.javers.core.json.typeadapter.util.LocalDateTimeTypeAdapter
.
-
-
Constructor Summary
Constructors Constructor Description BasicStringTypeAdapter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract T
deserialize(java.lang.String serializedValue)
Example deserialization for LocalDateTime:T
fromJson(com.google.gson.JsonElement json, com.google.gson.JsonDeserializationContext jsonDeserializationContext)
abstract java.lang.String
serialize(T sourceValue)
Example serialization for LocalDateTime:com.google.gson.JsonElement
toJson(T sourceValue, com.google.gson.JsonSerializationContext jsonSerializationContext)
-
Methods inherited from class org.javers.core.json.JsonTypeAdapterTemplate
getValueType, getValueTypes
-
-
-
-
Method Detail
-
serialize
public abstract java.lang.String serialize(T sourceValue)
Example serialization for LocalDateTime:public String serialize(LocalDateTime sourceValue) { return ISO_DATE_TIME_FORMATTER.print(sourceValue); }
- Parameters:
sourceValue
- not null
-
deserialize
public abstract T deserialize(java.lang.String serializedValue)
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
-
-