JsonTypeAdapter<T>public abstract class BasicStringTypeAdapter<T> extends JsonTypeAdapterTemplate<T>
JsonTypeAdapter.
Extend it if you need to represent your ValueType as single String and don't want to deal with Gson API.
org.javers.core.json.typeadapter.util.LocalDateTimeTypeAdapter.
| Constructor | Description |
|---|---|
BasicStringTypeAdapter() |
| 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) |
getValueType, getValueTypespublic abstract java.lang.String serialize(T sourceValue)
public String serialize(LocalDateTime sourceValue) {
return ISO_DATE_TIME_FORMATTER.print(sourceValue);
}
sourceValue - not nullpublic abstract T deserialize(java.lang.String serializedValue)
public LocalDateTime deserialize(String serializedValue) {
return ISO_DATE_TIME_FORMATTER.parseLocalDateTime(serializedValue);
}
serializedValue - not nullpublic T fromJson(com.google.gson.JsonElement json, com.google.gson.JsonDeserializationContext jsonDeserializationContext)
json - not null and not JsonNulljsonDeserializationContext - use it to invoke default deserialization on the specified objectpublic com.google.gson.JsonElement toJson(T sourceValue, com.google.gson.JsonSerializationContext jsonSerializationContext)
sourceValue - not nulljsonSerializationContext - use it to invoke default serialization on the specified object