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>
public abstract class BasicStringTypeAdapter<T> extends JsonTypeAdapterTemplate<T>
Convenient abstract implementation ofJsonTypeAdapter. Extend it if you need to represent yourValueTypeas a single String. For a concrete adapter implementation example seeLocalDateTimeTypeAdapter.
-
-
Constructor Summary
Constructors Constructor Description BasicStringTypeAdapter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Tdeserialize(java.lang.String serializedValue)Example deserialization for LocalDateTime:TfromJson(com.google.gson.JsonElement json, com.google.gson.JsonDeserializationContext jsonDeserializationContext)abstract java.lang.Stringserialize(T sourceValue)Example serialization for LocalDateTime:com.google.gson.JsonElementtoJson(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
-
-