java.lang.Object
tools.jackson.databind.jsontype.impl.TypeIdResolverBase
- All Implemented Interfaces:
Serializable,TypeIdResolver
- Direct Known Subclasses:
ClassNameIdResolver,SimpleNameIdResolver,TypeNameIdResolver
Partial base implementation of
TypeIdResolver: all custom implementations
are strongly recommended to extend this class, instead of directly
implementing TypeIdResolver.
Note that ALL sub-class need to re-implement
typeFromId(DatabindContext, String) method; otherwise implementation
will not work.
Note that instances created to be constructed from annotations
(JsonTypeIdResolver)
are always created using no-arguments constructor; protected constructor
is only used sub-classes.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Class<?>_resolveToParentAsNecessary(Class<?> cls) Helper method for ensuring we properly resolve cases where we don't want to use given instance class due to it being a specific inner class but rather enclosing (or parent) class.Helper method used to get a simple description of all known type ids, for use in error messages.Method that can be called to figure out type id to use for instances of base type (declared type of property).voidMethod that will be called once before any type resolution calls; used to initialize instance with configuration.typeFromId(DatabindContext context, String id) Method called to resolve type from given type identifier.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface tools.jackson.databind.jsontype.TypeIdResolver
getMechanism, idFromValue, idFromValueAndType
-
Field Details
-
_baseType
Common base type for all polymorphic instances handled.
-
-
Constructor Details
-
TypeIdResolverBase
protected TypeIdResolverBase() -
TypeIdResolverBase
-
-
Method Details
-
init
Description copied from interface:TypeIdResolverMethod that will be called once before any type resolution calls; used to initialize instance with configuration. This is necessary since instances may be created via reflection, without ability to call specific constructor to pass in configuration settings.- Specified by:
initin interfaceTypeIdResolver- Parameters:
bt- Base type for which this id resolver instance is used
-
idFromBaseType
Description copied from interface:TypeIdResolverMethod that can be called to figure out type id to use for instances of base type (declared type of property). This is usually only used for fallback handling, for cases where real type information is not available for some reason.- Specified by:
idFromBaseTypein interfaceTypeIdResolver
-
typeFromId
Description copied from interface:TypeIdResolverMethod called to resolve type from given type identifier.- Specified by:
typeFromIdin interfaceTypeIdResolver- Throws:
JacksonException
-
getDescForKnownTypeIds
Helper method used to get a simple description of all known type ids, for use in error messages.- Specified by:
getDescForKnownTypeIdsin interfaceTypeIdResolver
-
_resolveToParentAsNecessary
Helper method for ensuring we properly resolve cases where we don't want to use given instance class due to it being a specific inner class but rather enclosing (or parent) class. Specific case we know of currently are "enum subtypes", cases where simple Enum constant has overrides and uses generated sub-class if parent Enum type. In this case we need to ensure that we use the main/parent Enum type, not sub-class.- Parameters:
cls- Class to check and possibly resolve- Returns:
- Resolved class to use
- Since:
- 2.18.2
-