Package org.javers.core.json
Interface JsonTypeAdapter<T>
-
- Type Parameters:
T
- user type, mapped toValueType
orCustomType
- All Known Implementing Classes:
BasicStringTypeAdapter
,CdoSnapshotStateTypeAdapter
,JsonTypeAdapterTemplate
public interface JsonTypeAdapter<T>
JsonTypeAdapter allows to customize JSON serialization of yourValueType
orCustomType
in aJaversRepository
. Implementation shouldn't take care about nulls (nulls are handled by Gson engine). For a concrete adapter implementation example seeLocalDateTimeTypeAdapter
. Convenient template classes are available, seeBasicStringTypeAdapter
Usage with Vanilla JaversJavers javers = JaversBuilder.javers() .registerValueTypeAdapter(new MyTypeAdapter()) .build();
Usage with Javers Spring Boot starters
Simply register your JSON type adapters as Spring beans.- See Also:
JsonConverter
,JsonAdvancedTypeAdapter
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
fromJson(com.google.gson.JsonElement json, com.google.gson.JsonDeserializationContext jsonDeserializationContext)
java.util.List<java.lang.Class>
getValueTypes()
Target class (or classes), typicallyValueType
orCustomType
.com.google.gson.JsonElement
toJson(T sourceValue, com.google.gson.JsonSerializationContext jsonSerializationContext)
-
-
-
Method Detail
-
fromJson
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
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
-
getValueTypes
java.util.List<java.lang.Class> getValueTypes()
Target class (or classes), typicallyValueType
orCustomType
.
Each target class should have a no-argument constructor (public or private). If adapter is designed to handle single class, should return a List with one element — a supported class.
-
-