com.fasterxml.jackson.databind.jsontype.impl

## Class TypeNameIdResolver

- java.lang.Object
- - com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase
  - - com.fasterxml.jackson.databind.jsontype.impl.TypeNameIdResolver

All Implemented Interfaces:
  TypeIdResolver

    public class TypeNameIdResolver
    extends TypeIdResolverBase

### Field Summary

Fields
`protected boolean` `_caseInsensitive`
`protected MapperConfig<?>` `_config`
`protected Map<String,JavaType>` `_idToType` Mappings from type id to JavaType, used for deserialization.
`protected ConcurrentHashMap<String,String>` `_typeToId` Mappings from class name to type id, used for serialization.

### Fields inherited from class com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase

`_baseType, _typeFactory`

### Constructor Summary

Constructors
`protected` `TypeNameIdResolver(MapperConfig<?> config, JavaType baseType, ConcurrentHashMap<String,String> typeToId, HashMap<String,JavaType> idToType)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`protected static String` `_defaultTypeId(Class<?> cls)` If no name was explicitly given for a class, we will just use non-qualified class name
`protected JavaType` `_typeFromId(String id)`
`static TypeNameIdResolver` `construct(MapperConfig<?> config, JavaType baseType, Collection<NamedType> subtypes, boolean forSer, boolean forDeser)`
`String` `getDescForKnownTypeIds()` Helper method used to get a simple description of all known type ids, for use in error messages.
`JsonTypeInfo.Id` `getMechanism()` Accessor for mechanism that this resolver uses for determining type id from type.
`protected String` `idFromClass(Class<?> clazz)`
`String` `idFromValue(Object value)` Method called to serialize type of the type of given value as a String to include in serialized JSON content.
`String` `idFromValueAndType(Object value, Class<?> type)` Alternative method used for determining type from combination of value and type, using suggested type (that serializer provides) and possibly value of that type.
`String` `toString()`
`JavaType` `typeFromId(DatabindContext context, String id)` Method called to resolve type from given type identifier.

### Methods inherited from class com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase

`idFromBaseType, init`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### _config

    protected final MapperConfig<?> _config

#### _typeToId

    protected final ConcurrentHashMap<String,String> _typeToId

Mappings from class name to type id, used for serialization.

Since lazily constructed will require synchronization (either internal by type, or external)

#### _idToType

    protected final Map<String,JavaType> _idToType

Mappings from type id to JavaType, used for deserialization.

Eagerly constructed, not modified, can use regular unsynchronized `Map`.

#### _caseInsensitive

    protected final boolean _caseInsensitive

Since:
  2.11

### Constructor Detail

#### TypeNameIdResolver

    protected TypeNameIdResolver(MapperConfig<?> config,
                                 JavaType baseType,
                                 ConcurrentHashMap<String,String> typeToId,
                                 HashMap<String,JavaType> idToType)

### Method Detail

#### construct

    public static TypeNameIdResolver construct(MapperConfig<?> config,
                                               JavaType baseType,
                                               Collection<NamedType> subtypes,
                                               boolean forSer,
                                               boolean forDeser)

#### getMechanism

    public JsonTypeInfo.Id getMechanism()

Description copied from interface: `TypeIdResolver`
Accessor for mechanism that this resolver uses for determining type id from type. Mostly informational; not required to be called or used.

#### idFromValue

    public String idFromValue(Object value)

Description copied from interface: `TypeIdResolver`
Method called to serialize type of the type of given value as a String to include in serialized JSON content.

#### idFromClass

    protected String idFromClass(Class<?> clazz)

#### idFromValueAndType

    public String idFromValueAndType(Object value,
                                     Class<?> type)

Description copied from interface: `TypeIdResolver`
Alternative method used for determining type from combination of value and type, using suggested type (that serializer provides) and possibly value of that type. Most common implementation will use suggested type as is.

#### typeFromId

    public JavaType typeFromId(DatabindContext context,
                               String id)

Description copied from interface: `TypeIdResolver`
Method called to resolve type from given type identifier.

Specified by:
  `typeFromId` in interface `TypeIdResolver`
Overrides:
  `typeFromId` in class `TypeIdResolverBase`

#### _typeFromId

    protected JavaType _typeFromId(String id)

#### getDescForKnownTypeIds

    public String getDescForKnownTypeIds()

Description copied from class: `TypeIdResolverBase`
Helper method used to get a simple description of all known type ids, for use in error messages.

Specified by:
  `getDescForKnownTypeIds` in interface `TypeIdResolver`
Overrides:
  `getDescForKnownTypeIds` in class `TypeIdResolverBase`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

#### _defaultTypeId

    protected static String _defaultTypeId(Class<?> cls)

If no name was explicitly given for a class, we will just use non-qualified class name