Class TypeIdResolverBase

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.Class<?> _resolveToParentAsNecessary​(java.lang.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.
      java.lang.String getDescForKnownTypeIds()
      Helper method used to get a simple description of all known type ids, for use in error messages.
      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).
      void init​(JavaType bt)
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • _typeFactory

        protected final TypeFactory _typeFactory
      • _baseType

        protected final JavaType _baseType
        Common base type for all polymorphic instances handled.
    • Constructor Detail

      • TypeIdResolverBase

        protected TypeIdResolverBase()
      • TypeIdResolverBase

        protected TypeIdResolverBase​(JavaType baseType,
                                     TypeFactory typeFactory)
    • Method Detail

      • init

        public void init​(JavaType bt)
        Description copied from interface: TypeIdResolver
        Method 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:
        init in interface TypeIdResolver
        Parameters:
        bt - Base type for which this id resolver instance is used
      • idFromBaseType

        public java.lang.String idFromBaseType()
        Description copied from interface: TypeIdResolver
        Method 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:
        idFromBaseType in interface TypeIdResolver
      • typeFromId

        public JavaType typeFromId​(DatabindContext context,
                                   java.lang.String id)
                            throws java.io.IOException
        Description copied from interface: TypeIdResolver
        Method called to resolve type from given type identifier.
        Specified by:
        typeFromId in interface TypeIdResolver
        Throws:
        java.io.IOException
      • getDescForKnownTypeIds

        public java.lang.String getDescForKnownTypeIds()
        Helper method used to get a simple description of all known type ids, for use in error messages.
        Specified by:
        getDescForKnownTypeIds in interface TypeIdResolver
      • _resolveToParentAsNecessary

        protected java.lang.Class<?> _resolveToParentAsNecessary​(java.lang.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. 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