public abstract class BasicStringTypeAdapter<T> extends Object implements JsonTypeAdapter<T>
JsonTypeAdapter.
Extend it if you need to represent unwrap (T) as single String and don't want to deal with Gson API.
LocalDateTimeTypeAdapter.
| Constructor and Description |
|---|
BasicStringTypeAdapter() |
| Modifier and Type | Method and Description |
|---|---|
abstract T |
deserialize(String serializedValue)
Example deserialization for LocalDateTime:
public LocalDateTime deserialize(String serializedValue) {
return ISO_FORMATTER.parseLocalDateTime(serializedValue);
}
|
T |
fromJson(com.google.gson.JsonElement json,
com.google.gson.JsonDeserializationContext jsonDeserializationContext) |
abstract String |
serialize(T sourceValue)
Example serialization for LocalDateTime:
public String serialize(LocalDateTime sourceValue) {
return ISO_FORMATTER.print(sourceValue);
}
|
com.google.gson.JsonElement |
toJson(T sourceValue,
com.google.gson.JsonSerializationContext jsonSerializationContext) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetValueTypepublic abstract String serialize(T sourceValue)
public String serialize(LocalDateTime sourceValue) {
return ISO_FORMATTER.print(sourceValue);
}
sourceValue - not nullpublic abstract T deserialize(String serializedValue)
public LocalDateTime deserialize(String serializedValue) {
return ISO_FORMATTER.parseLocalDateTime(serializedValue);
}
serializedValue - not nullpublic T fromJson(com.google.gson.JsonElement json, com.google.gson.JsonDeserializationContext jsonDeserializationContext)
fromJson in interface JsonTypeAdapter<T>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)
toJson in interface JsonTypeAdapter<T>sourceValue - not nulljsonSerializationContext - use it to invoke default serialization on the specified objectCopyright © 2014. All rights reserved.