Class SimpleNameIdResolver
- java.lang.Object
-
- com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase
-
- com.fasterxml.jackson.databind.jsontype.impl.SimpleNameIdResolver
-
- All Implemented Interfaces:
TypeIdResolver,java.io.Serializable
public class SimpleNameIdResolver extends TypeIdResolverBase implements java.io.Serializable
TypeIdResolverimplementation that converts using explicitly (annotation-) specified type names and maps to implementation classes; or, in absence of annotated type name, defaults to simpleClassnames (obtained withClass.getSimpleName(). Basically same asTypeNameIdResolverexcept for default to "simple" and not "full" class name.- Since:
- 2.16
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean_caseInsensitiveprotected MapperConfig<?>_configprotected java.util.Map<java.lang.String,JavaType>_idToTypeMappings from type id to JavaType, used for deserialization.protected java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.String>_typeToIdMappings 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 Modifier Constructor Description protectedSimpleNameIdResolver(MapperConfig<?> config, JavaType baseType, java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.String> typeToId, java.util.HashMap<java.lang.String,JavaType> idToType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.lang.String_defaultTypeId(java.lang.Class<?> cls)If no name was explicitly given for a class, we will just use simple class nameprotected JavaType_typeFromId(java.lang.String id)static SimpleNameIdResolverconstruct(MapperConfig<?> config, JavaType baseType, java.util.Collection<NamedType> subtypes, boolean forSer, boolean forDeser)java.lang.StringgetDescForKnownTypeIds()Helper method used to get a simple description of all known type ids, for use in error messages.com.fasterxml.jackson.annotation.JsonTypeInfo.IdgetMechanism()Accessor for mechanism that this resolver uses for determining type id from type.protected java.lang.StringidFromClass(java.lang.Class<?> clazz)java.lang.StringidFromValue(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.StringidFromValueAndType(java.lang.Object value, java.lang.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.java.lang.StringtoString()JavaTypetypeFromId(DatabindContext context, java.lang.String id)Method called to resolve type from given type identifier.-
Methods inherited from class com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase
idFromBaseType, init
-
-
-
-
Field Detail
-
_config
protected final MapperConfig<?> _config
-
_typeToId
protected final java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.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 java.util.Map<java.lang.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
-
-
Constructor Detail
-
SimpleNameIdResolver
protected SimpleNameIdResolver(MapperConfig<?> config, JavaType baseType, java.util.concurrent.ConcurrentHashMap<java.lang.String,java.lang.String> typeToId, java.util.HashMap<java.lang.String,JavaType> idToType)
-
-
Method Detail
-
construct
public static SimpleNameIdResolver construct(MapperConfig<?> config, JavaType baseType, java.util.Collection<NamedType> subtypes, boolean forSer, boolean forDeser)
-
getMechanism
public com.fasterxml.jackson.annotation.JsonTypeInfo.Id getMechanism()
Description copied from interface:TypeIdResolverAccessor for mechanism that this resolver uses for determining type id from type. Mostly informational; not required to be called or used.- Specified by:
getMechanismin interfaceTypeIdResolver
-
idFromValue
public java.lang.String idFromValue(java.lang.Object value)
Description copied from interface:TypeIdResolverMethod called to serialize type of the type of given value as a String to include in serialized JSON content.- Specified by:
idFromValuein interfaceTypeIdResolver
-
idFromClass
protected java.lang.String idFromClass(java.lang.Class<?> clazz)
-
idFromValueAndType
public java.lang.String idFromValueAndType(java.lang.Object value, java.lang.Class<?> type)Description copied from interface:TypeIdResolverAlternative 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.- Specified by:
idFromValueAndTypein interfaceTypeIdResolver
-
typeFromId
public JavaType typeFromId(DatabindContext context, java.lang.String id)
Description copied from interface:TypeIdResolverMethod called to resolve type from given type identifier.- Specified by:
typeFromIdin interfaceTypeIdResolver- Overrides:
typeFromIdin classTypeIdResolverBase
-
_typeFromId
protected JavaType _typeFromId(java.lang.String id)
-
getDescForKnownTypeIds
public java.lang.String getDescForKnownTypeIds()
Description copied from class:TypeIdResolverBaseHelper method used to get a simple description of all known type ids, for use in error messages.- Specified by:
getDescForKnownTypeIdsin interfaceTypeIdResolver- Overrides:
getDescForKnownTypeIdsin classTypeIdResolverBase
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
_defaultTypeId
protected static java.lang.String _defaultTypeId(java.lang.Class<?> cls)
If no name was explicitly given for a class, we will just use simple class name
-
-