Skip to content

Commit 8306e6c

Browse files
authored
Add AnnotationIntrospector.findPolymorphicTypeInfo()
1 parent 63a7b1d commit 8306e6c

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/main/java/com/fasterxml/jackson/databind/AnnotationIntrospector.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,20 @@ public VisibilityChecker<?> findAutoDetectVisibility(AnnotatedClass ac,
484484
/**********************************************************
485485
*/
486486

487+
/**
488+
* Method for checking whether given Class or Property Accessor specifies
489+
* polymorphic type-handling information, to indicate need for polymorphic
490+
* handling.
491+
*
492+
* @param config Effective mapper configuration in use
493+
* @param ann Annotated entity to introspect
494+
*
495+
* @since 2.16 (backported from Jackson 3.0)
496+
*/
497+
public JsonTypeInfo.Value findPolymorphicTypeInfo(MapperConfig<?> config, Annotated ann) {
498+
return null;
499+
}
500+
487501
/**
488502
* Method for checking if given class has annotations that indicate
489503
* that specific type resolver is to be used for handling instances.

src/main/java/com/fasterxml/jackson/databind/introspect/AnnotationIntrospectorPair.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,19 @@ public VisibilityChecker<?> findAutoDetectVisibility(AnnotatedClass ac,
231231
/******************************************************
232232
*/
233233

234+
/**
235+
* @since 2.16 (backported from Jackson 3.0)
236+
*/
237+
@Override
238+
public JsonTypeInfo.Value findPolymorphicTypeInfo(MapperConfig<?> config, Annotated ann)
239+
{
240+
JsonTypeInfo.Value v = _primary.findPolymorphicTypeInfo(config, ann);
241+
if (v == null) {
242+
v = _secondary.findPolymorphicTypeInfo(config, ann);
243+
}
244+
return v;
245+
}
246+
234247
@Override
235248
public TypeResolverBuilder<?> findTypeResolver(MapperConfig<?> config,
236249
AnnotatedClass ac, JavaType baseType)

src/main/java/com/fasterxml/jackson/databind/introspect/JacksonAnnotationIntrospector.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,16 @@ public PropertyName findRenameByField(MapperConfig<?> config,
593593
/**********************************************************
594594
*/
595595

596+
/**
597+
* @since 2.16 (backported from Jackson 3.0)
598+
*/
599+
@Override
600+
public JsonTypeInfo.Value findPolymorphicTypeInfo(MapperConfig<?> config, Annotated ann)
601+
{
602+
JsonTypeInfo t = _findAnnotation(ann, JsonTypeInfo.class);
603+
return (t == null) ? null : JsonTypeInfo.Value.from(t);
604+
}
605+
596606
@Override
597607
public TypeResolverBuilder<?> findTypeResolver(MapperConfig<?> config,
598608
AnnotatedClass ac, JavaType baseType)

0 commit comments

Comments
 (0)