Class AbstractCalendarAdapter<T>
java.lang.Object
com.google.gson.TypeAdapter<T>
com.sap.cloud.sdk.s4hana.datamodel.odata.adapter.AbstractCalendarAdapter<T>
- Type Parameters:
T
- The type this adapter should parse.
- Direct Known Subclasses:
LocalDateTimeAdapter
,LocalTimeAdapter
,ZonedDateTimeAdapter
public abstract class AbstractCalendarAdapter<T>
extends com.google.gson.TypeAdapter<T>
Abstract base class to be used to easily parse fields which can be read as a
Calendar
object as a Gson
TypeAdapter
.
This may be used to specify an adapter for the new Java date API (e.g. LocalDateTime
) based on a
common conversion logic. This way the logic is split the following way:
General Conversion logic | AbstractTypeConverter subclasses (*CalendarConverter) |
Gson Adapter | AbstractCalendarAdapter subclasses |
Jackson (De)Serializer | AbstractJacksonCalendar(De)Serializer and subclasses |
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ConvertedObject<T>
convertStringToType
(String jsonString) Converts a string value read from a json property as an instance of the type to be created by this adapter.protected abstract ConvertedObject<String>
convertTypeToString
(T entity) Converts an instance of the type handled by this adapter into a string that can be written as a json value.read
(com.google.gson.stream.JsonReader jsonReader) void
Methods inherited from class com.google.gson.TypeAdapter
fromJson, fromJson, fromJsonTree, nullSafe, toJson, toJson, toJsonTree
-
Constructor Details
-
AbstractCalendarAdapter
public AbstractCalendarAdapter()
-
-
Method Details
-
convertStringToType
Converts a string value read from a json property as an instance of the type to be created by this adapter.- Parameters:
jsonString
- The string value of a json property.- Returns:
- A
ConvertedObject
instance containing the resulting object, or is empty if conversion was not possible.
-
convertTypeToString
Converts an instance of the type handled by this adapter into a string that can be written as a json value.- Parameters:
entity
- The entity to convert into a String- Returns:
- A
ConvertedObject
instance containing the resulting string, or is empty if conversion was not possible.
-
write
public void write(@Nonnull com.google.gson.stream.JsonWriter out, @Nullable T value) throws IOException - Specified by:
write
in classcom.google.gson.TypeAdapter<T>
- Throws:
IOException
-
read
- Specified by:
read
in classcom.google.gson.TypeAdapter<T>
- Throws:
IOException
-