public abstract class BasicStringTypeAdapter<T> extends Object implements JsonTypeAdapter<T>
JsonTypeAdapter.
Extend it if you need to represent value (T) as single String and don't want to deal with JSON 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) |
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) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetTypepublic abstract String serialize(T sourceValue)
public String serialize(LocalDateTime sourceValue) {
return ISO_FORMATTER.print(sourceValue);
}
public abstract T deserialize(String serializedValue)
public LocalDateTime deserialize(String serializedValue) {
return ISO_FORMATTER.parseLocalDateTime(serializedValue);
}
public T fromJson(com.google.gson.JsonElement json)
fromJson in interface JsonTypeAdapter<T>public com.google.gson.JsonElement toJson(T sourceValue)
toJson in interface JsonTypeAdapter<T>Copyright © 2013. All rights reserved.