public interface TypeIdResolver
TypeSerializer
,
TypeDeserializer
) for converting
between type and matching id; id is stored in JSON and needed for
creating instances of proper subtypes when deserializing values.
NOTE: it is strongly recommended that developers always extend
abstract base class TypeIdResolverBase
instead of directly implementing this interface; this helps prevent
breakage in case new methds need to be added in this interface (something
we try to avoid doing; but which may be necessary in some cases).
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getDescForKnownTypeIds()
Method called for error-reporting and diagnostics purposes.
|
JsonTypeInfo.Id |
getMechanism()
Accessor for mechanism that this resolver uses for determining
type id from type.
|
java.lang.String |
idFromBaseType()
Method that can be called to figure out type id to use for instances
of base type (declared type of property).
|
java.lang.String |
idFromValue(java.lang.Object value)
Method called to serialize type of the type of given value
as a String to include in serialized JSON content.
|
java.lang.String |
idFromValueAndType(java.lang.Object value,
java.lang.Class<?> suggestedType)
Alternative method used for determining type from combination of
value and type, using suggested type (that serializer provides)
and possibly value of that type.
|
void |
init(JavaType baseType)
Method that will be called once before any type resolution calls;
used to initialize instance with configuration.
|
JavaType |
typeFromId(DatabindContext context,
java.lang.String id)
Method called to resolve type from given type identifier.
|
void init(JavaType baseType)
baseType
- Base type for which this id resolver instance is
usedjava.lang.String idFromValue(java.lang.Object value)
java.lang.String idFromValueAndType(java.lang.Object value, java.lang.Class<?> suggestedType)
java.lang.String idFromBaseType()
JavaType typeFromId(DatabindContext context, java.lang.String id) throws java.io.IOException
java.io.IOException
java.lang.String getDescForKnownTypeIds()
TypeIdResolverBase
JsonTypeInfo.Id getMechanism()
Copyright © 2010 - 2020 Adobe. All Rights Reserved