/** * @since 2.9 */ public void registerSubtypes(Collection<Class<?>> subtypes) { getSubtypeResolver().registerSubtypes(subtypes); }
/** * Method for finding out all reachable subtypes for given type, * such that access is by type id, * typically needed for deserialization (converting from type id to type). * * @param baseType Effective property base type to use; may differ from * actual type of property; for structured types it is content (value) type and NOT * structured type. * * @since 2.6 */ public Collection<NamedType> collectAndResolveSubtypesByTypeId(MapperConfig<?> config, AnnotatedClass baseType) { // for backwards compatibility... return collectAndResolveSubtypes(baseType, config, config.getAnnotationIntrospector()); }
/** * @deprecated Since 2.6 Use either * {@link #collectAndResolveSubtypesByClass(MapperConfig, AnnotatedClass)} * or {@link #collectAndResolveSubtypesByTypeId(MapperConfig, AnnotatedClass)} * instead. */ @Deprecated public Collection<NamedType> collectAndResolveSubtypes(AnnotatedClass baseType, MapperConfig<?> config, AnnotationIntrospector ai) { return collectAndResolveSubtypesByClass(config, baseType); } }
/** * Method called to create a type information deserializer for values of * given non-container property, if one is needed. * If not needed (no polymorphic handling configured for property), should return null. *<p> * Note that this method is only called for non-container bean properties, * and not for values in container types or root values (or container properties) * * @param baseType Declared base type of the value to deserializer (actual * deserializer type will be this type or its subtype) * * @return Type deserializer to use for given base type, if one is needed; null if not. */ public TypeDeserializer findPropertyTypeDeserializer(DeserializationConfig config, JavaType baseType, AnnotatedMember annotated) throws JsonMappingException { AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyTypeResolver(config, annotated, baseType); // Defaulting: if no annotations on member, check value class if (b == null) { return findTypeDeserializer(config, baseType); } // but if annotations found, may need to resolve subtypes: Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByTypeId( config, annotated, baseType); return b.buildTypeDeserializer(config, baseType, subtypes); }
/** * Method called to find and create a type information deserializer for values of * given container (list, array, map) property, if one is needed. * If not needed (no polymorphic handling configured for property), should return null. *<p> * Note that this method is only called for container bean properties, * and not for values in container types or root values (or non-container properties) * * @param containerType Type of property; must be a container type * @param propertyEntity Field or method that contains container property */ public TypeDeserializer findPropertyContentTypeDeserializer(DeserializationConfig config, JavaType containerType, AnnotatedMember propertyEntity) throws JsonMappingException { AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyContentTypeResolver(config, propertyEntity, containerType); JavaType contentType = containerType.getContentType(); // Defaulting: if no annotations on member, check class if (b == null) { return findTypeDeserializer(config, contentType); } // but if annotations found, may need to resolve subtypes: Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByTypeId( config, propertyEntity, contentType); return b.buildTypeDeserializer(config, contentType, subtypes); }
/** * Method for finding out all reachable subtypes for a property specified * by given element (method or field), * such that access is by type, * typically needed for serialization (converting from type to type name). * * @param baseType Effective property base type to use; may differ from * actual type of property; for structured types it is content (value) type and NOT * structured type. * * @since 2.6 */ public Collection<NamedType> collectAndResolveSubtypesByClass(MapperConfig<?> config, AnnotatedMember property, JavaType baseType) { // for backwards compatibility... return collectAndResolveSubtypes(property, config, config.getAnnotationIntrospector(), baseType); }
/** * Method for registering specified class as a subtype, so that * typename-based resolution can link supertypes to subtypes * (as an alternative to using annotations). * Type for given class is determined from appropriate annotation; * or if missing, default name (unqualified class name) */ public void registerSubtypes(Class<?>... classes) { getSubtypeResolver().registerSubtypes(classes); }
/** * @deprecated Since 2.6 Use either * {@link #collectAndResolveSubtypesByClass(MapperConfig, AnnotatedMember, JavaType)} * or {@link #collectAndResolveSubtypesByTypeId(MapperConfig, AnnotatedMember, JavaType)} * instead. */ @Deprecated public Collection<NamedType> collectAndResolveSubtypes(AnnotatedMember property, MapperConfig<?> config, AnnotationIntrospector ai, JavaType baseType) { return collectAndResolveSubtypesByClass(config, property, baseType); }
/** * Helper method that is needed to properly handle polymorphic referenced * types, such as types referenced by {@link java.util.concurrent.atomic.AtomicReference}, * or various "optional" types. * * @since 2.4 */ public TypeDeserializer findTypeDeserializer(JavaType baseType) throws JsonMappingException { BeanDescription bean = introspectClassAnnotations(baseType.getRawClass()); AnnotatedClass ac = bean.getClassInfo(); TypeResolverBuilder<?> b = getAnnotationIntrospector().findTypeResolver(this, ac, baseType); /* Ok: if there is no explicit type info handler, we may want to * use a default. If so, config object knows what to use. */ Collection<NamedType> subtypes = null; if (b == null) { b = getDefaultTyper(baseType); if (b == null) { return null; } } else { subtypes = getSubtypeResolver().collectAndResolveSubtypesByTypeId(this, ac); } return b.buildTypeDeserializer(this, baseType, subtypes); } }
/** * Method for finding out all reachable subtypes for given type, * such that access is by type, * typically needed for serialization (converting from type to type name). * * @param baseType Effective property base type to use; may differ from * actual type of property; for structured types it is content (value) type and NOT * structured type. * * @since 2.6 */ public Collection<NamedType> collectAndResolveSubtypesByClass(MapperConfig<?> config, AnnotatedClass baseType) { // for backwards compatibility... return collectAndResolveSubtypes(baseType, config, config.getAnnotationIntrospector()); }
/** * Method for registering specified class as a subtype, so that * typename-based resolution can link supertypes to subtypes * (as an alternative to using annotations). * Name may be provided as part of argument, but if not will * be based on annotations or use default name (unqualified * class name). */ public void registerSubtypes(NamedType... types) { getSubtypeResolver().registerSubtypes(types); }
/** * Method called to create a type information serializer for values of given * non-container property * if one is needed. If not needed (no polymorphic handling configured), should * return null. * * @param baseType Declared type to use as the base type for type information serializer * * @return Type serializer to use for property values, if one is needed; null if not. */ public TypeSerializer findPropertyTypeSerializer(JavaType baseType, SerializationConfig config, AnnotatedMember accessor) throws JsonMappingException { AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyTypeResolver(config, accessor, baseType); TypeSerializer typeSer; // Defaulting: if no annotations on member, check value class if (b == null) { typeSer = createTypeSerializer(config, baseType); } else { Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByClass( config, accessor, baseType); typeSer = b.buildTypeSerializer(config, baseType, subtypes); } return typeSer; }
subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByTypeId(config, ac);
/** * Method for finding out all reachable subtypes for a property specified * by given element (method or field), * such that access is by type id, * typically needed for deserialization (converting from type id to type). * * @param baseType Effective property base type to use; may differ from * actual type of property; for structured types it is content (value) type and NOT * structured type. * * @since 2.6 */ public Collection<NamedType> collectAndResolveSubtypesByTypeId(MapperConfig<?> config, AnnotatedMember property, JavaType baseType) { // for backwards compatibility... return collectAndResolveSubtypes(property, config, config.getAnnotationIntrospector(), baseType); }
/** * Method for registering specified class as a subtype, so that * typename-based resolution can link supertypes to subtypes * (as an alternative to using annotations). * Type for given class is determined from appropriate annotation; * or if missing, default name (unqualified class name) */ public void registerSubtypes(Class<?>... classes) { getSubtypeResolver().registerSubtypes(classes); }
/** * Method called to create a type information serializer for values of given * container property * if one is needed. If not needed (no polymorphic handling configured), should * return null. * * @param containerType Declared type of the container to use as the base type for type information serializer * * @return Type serializer to use for property value contents, if one is needed; null if not. */ public TypeSerializer findPropertyContentTypeSerializer(JavaType containerType, SerializationConfig config, AnnotatedMember accessor) throws JsonMappingException { JavaType contentType = containerType.getContentType(); AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyContentTypeResolver(config, accessor, containerType); TypeSerializer typeSer; // Defaulting: if no annotations on member, check value class if (b == null) { typeSer = createTypeSerializer(config, contentType); } else { Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByClass(config, accessor, contentType); typeSer = b.buildTypeSerializer(config, contentType, subtypes); } return typeSer; }
/** * Method called to create a type information deserializer for values of * given non-container property, if one is needed. * If not needed (no polymorphic handling configured for property), should return null. *<p> * Note that this method is only called for non-container bean properties, * and not for values in container types or root values (or container properties) * * @param baseType Declared base type of the value to deserializer (actual * deserializer type will be this type or its subtype) * * @return Type deserializer to use for given base type, if one is needed; null if not. */ public TypeDeserializer findPropertyTypeDeserializer(DeserializationConfig config, JavaType baseType, AnnotatedMember annotated) throws JsonMappingException { AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyTypeResolver(config, annotated, baseType); // Defaulting: if no annotations on member, check value class if (b == null) { return findTypeDeserializer(config, baseType); } // but if annotations found, may need to resolve subtypes: Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByTypeId( config, annotated, baseType); return b.buildTypeDeserializer(config, baseType, subtypes); }
/** * Method for finding out all reachable subtypes for a property specified * by given element (method or field), * such that access is by type id, * typically needed for deserialization (converting from type id to type). * * @param baseType Effective property base type to use; may differ from * actual type of property; for structured types it is content (value) type and NOT * structured type. * * @since 2.6 */ public Collection<NamedType> collectAndResolveSubtypesByTypeId(MapperConfig<?> config, AnnotatedMember property, JavaType baseType) { // for backwards compatibility... return collectAndResolveSubtypes(property, config, config.getAnnotationIntrospector(), baseType); }
/** * Method for registering specified class as a subtype, so that * typename-based resolution can link supertypes to subtypes * (as an alternative to using annotations). * Type for given class is determined from appropriate annotation; * or if missing, default name (unqualified class name) */ public void registerSubtypes(Class<?>... classes) { getSubtypeResolver().registerSubtypes(classes); }
/** * Method called to construct a type serializer for values with given declared * base type. This is called for values other than those of bean property * types. */ @Override public TypeSerializer createTypeSerializer(SerializationConfig config, JavaType baseType) { BeanDescription bean = config.introspectClassAnnotations(baseType.getRawClass()); AnnotatedClass ac = bean.getClassInfo(); AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findTypeResolver(config, ac, baseType); /* Ok: if there is no explicit type info handler, we may want to * use a default. If so, config object knows what to use. */ Collection<NamedType> subtypes = null; if (b == null) { b = config.getDefaultTyper(baseType); } else { subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByClass(config, ac); } if (b == null) { return null; } // 10-Jun-2015, tatu: Since not created for Bean Property, no need for post-processing // wrt EXTERNAL_PROPERTY return b.buildTypeSerializer(config, baseType, subtypes); }