Top Description Fields Constructors Methods
com.fasterxml.jackson.dataformat.ion.polymorphism

public Class IonAnnotationIntrospector

extends NopAnnotationIntrospector
Class Inheritance
Imports
com.fasterxml.jackson.annotation.JsonTypeInfo, com.fasterxml.jackson.databind.JavaType, com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver, .JsonTypeResolver, com.fasterxml.jackson.databind.cfg.MapperConfig, com.fasterxml.jackson.databind.introspect.AnnotatedClass, .NopAnnotationIntrospector, com.fasterxml.jackson.databind.jsontype.TypeIdResolver, .TypeResolverBuilder

A Jackson com.fasterxml.jackson.databind.AnnotationIntrospector (essentially an interceptor for serializer/deserializer construction) that provides type serializer/deserializers that write/read Ion type annotations.

The logic in this class is very similar to com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector! We both look at the @JsonTypeResolver, etc annotations and try to make type resolvers.

This class adds a resolveAllTypes override, which allows for universal polymorphism without needing any annotations or mixins, and also permits top-level polymorphism -- deserialize to any object without providing its actual type, as long as type information was serialized. (i.e., ObjectMapper#readValue(serializedData, Object.class))

Note

the provided com.fasterxml.jackson.databind.jsontype.TypeSerializer will only write type annotations if the configured TypeIdResolver returns non-null.

Note

com.fasterxml.jackson.databind.jsontype.TypeDeserializer are actually full-on value deserializers -- all deserialization logic goes through them (unlike TypeSerializers, which just write the type metadata).

Field Summary

Modifier and TypeField and Description
private final boolean
private static final long
Inherited from com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector:
instance

Constructor Summary

AccessConstructor and Description
public
IonAnnotationIntrospector(boolean resolveAllTypes)

Method Summary

Modifier and TypeMethod and Description
protected TypeIdResolver
public TypeResolverBuilder<?>

Returns:

a type resolver builder that reads and writes Ion type annotations, or null
findTypeResolver
(MapperConfig<?>
a serialization or deserialization config object
config
,
AnnotatedClass
an AnnotatedClass representing a (statically configured) base type for type resolution
ac
,
JavaType
a JavaType representing the same class
baseType
)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findTypeResolver.

Provides a TypeResolverBuilder if the AnnotatedClass is enabled for type resolving, and a TypeIdResolver can be instantiated.

protected boolean
Inherited from com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector:
version

Field Detail

resolveAllTypesback to summary
private final boolean resolveAllTypes
serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector.serialVersionUID.

Constructor Detail

IonAnnotationIntrospectorback to summary
public IonAnnotationIntrospector(boolean resolveAllTypes)

Method Detail

defaultIdResolverback to summary
protected TypeIdResolver defaultIdResolver(MapperConfig<?> config, JavaType baseType)
findTypeResolverback to summary
public TypeResolverBuilder<?> findTypeResolver(MapperConfig<?> config, AnnotatedClass ac, JavaType baseType)

Overrides com.fasterxml.jackson.databind.AnnotationIntrospector.findTypeResolver.

Provides a TypeResolverBuilder if the AnnotatedClass is enabled for type resolving, and a TypeIdResolver can be instantiated.

The AnnotatedClass is enabled for type resolving if either resolveAllTypes is set, or shouldResolveType() returns true.

We look for a TypeIdResolver by checking for a JsonTypeIdResolver annotation, and fallback to defaultIdResolver().

Parameters
config:MapperConfig<?>

a serialization or deserialization config object

ac:AnnotatedClass

an AnnotatedClass representing a (statically configured) base type for type resolution

baseType:JavaType

a JavaType representing the same class

Returns:TypeResolverBuilder<?>

a type resolver builder that reads and writes Ion type annotations, or null

Annotations
@Override
shouldResolveTypeback to summary
protected boolean shouldResolveType(AnnotatedClass ac)