@@ -1508,27 +1508,29 @@ protected PropertyName _findConstructorName(Annotated a)
1508
1508
protected TypeResolverBuilder <?> _findTypeResolver (MapperConfig <?> config ,
1509
1509
Annotated ann , JavaType baseType )
1510
1510
{
1511
+ // since 2.16 : backporting {@link JsonTypeInfo.Value} from 3.0
1512
+ JsonTypeInfo .Value typeInfo = findPolymorphicTypeInfo (config , ann );
1513
+
1511
1514
// First: maybe we have explicit type resolver?
1512
1515
TypeResolverBuilder <?> b ;
1513
- JsonTypeInfo info = _findAnnotation (ann , JsonTypeInfo .class );
1514
1516
JsonTypeResolver resAnn = _findAnnotation (ann , JsonTypeResolver .class );
1515
1517
1516
1518
if (resAnn != null ) {
1517
- if (info == null ) {
1519
+ if (typeInfo == null ) {
1518
1520
return null ;
1519
1521
}
1520
1522
// let's not try to force access override (would need to pass
1521
1523
// settings through if we did, since that's not doable on some platforms)
1522
1524
b = config .typeResolverBuilderInstance (ann , resAnn .value ());
1523
1525
} else { // if not, use standard one, if indicated by annotations
1524
- if (info == null ) {
1526
+ if (typeInfo == null ) {
1525
1527
return null ;
1526
1528
}
1527
1529
// bit special; must return 'marker' to block use of default typing:
1528
- if (info . use () == JsonTypeInfo .Id .NONE ) {
1530
+ if (typeInfo . getIdType () == JsonTypeInfo .Id .NONE ) {
1529
1531
return _constructNoTypeResolverBuilder ();
1530
1532
}
1531
- b = _constructStdTypeResolverBuilder ();
1533
+ b = _constructStdTypeResolverBuilder (config , typeInfo , baseType );
1532
1534
}
1533
1535
// Does it define a custom type id resolver?
1534
1536
JsonTypeIdResolver idResInfo = _findAnnotation (ann , JsonTypeIdResolver .class );
@@ -1537,26 +1539,24 @@ protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config,
1537
1539
if (idRes != null ) {
1538
1540
idRes .init (baseType );
1539
1541
}
1540
- b = b .init (info .use (), idRes );
1541
1542
// 13-Aug-2011, tatu: One complication; external id only works for properties;
1542
1543
// so if declared for a Class, we will need to map it to "PROPERTY"
1543
1544
// instead of "EXTERNAL_PROPERTY"
1544
- JsonTypeInfo .As inclusion = info . include ();
1545
+ JsonTypeInfo .As inclusion = typeInfo . getInclusionType ();
1545
1546
if (inclusion == JsonTypeInfo .As .EXTERNAL_PROPERTY && (ann instanceof AnnotatedClass )) {
1546
- inclusion = JsonTypeInfo .As .PROPERTY ;
1547
+ typeInfo = typeInfo . withInclusionType ( JsonTypeInfo .As .PROPERTY ) ;
1547
1548
}
1548
- b = b .inclusion (inclusion );
1549
- b = b .typeProperty (info .property ());
1550
- Class <?> defaultImpl = info .defaultImpl ();
1549
+ Class <?> defaultImpl = typeInfo .getDefaultImpl ();
1551
1550
1552
1551
// 08-Dec-2014, tatu: To deprecate `JsonTypeInfo.None` we need to use other placeholder(s);
1553
1552
// and since `java.util.Void` has other purpose (to indicate "deser as null"), we'll instead
1554
1553
// use `JsonTypeInfo.class` itself. But any annotation type will actually do, as they have no
1555
1554
// valid use (cannot instantiate as default)
1556
- if (defaultImpl != JsonTypeInfo .None .class && !defaultImpl .isAnnotation ()) {
1557
- b = b . defaultImpl (defaultImpl );
1555
+ if (defaultImpl != null && defaultImpl != JsonTypeInfo .None .class && !defaultImpl .isAnnotation ()) {
1556
+ typeInfo = typeInfo . withDefaultImpl (defaultImpl );
1558
1557
}
1559
- b = b .typeIdVisibility (info .visible ());
1558
+
1559
+ b = b .init (typeInfo , idRes );
1560
1560
return b ;
1561
1561
}
1562
1562
@@ -1568,6 +1568,17 @@ protected StdTypeResolverBuilder _constructStdTypeResolverBuilder() {
1568
1568
return new StdTypeResolverBuilder ();
1569
1569
}
1570
1570
1571
+ /**
1572
+ * Helper method for constructing standard {@link TypeResolverBuilder}
1573
+ * implementation.
1574
+ *
1575
+ * @since 2.16 (backported from Jackson 3.0)
1576
+ */
1577
+ protected TypeResolverBuilder <?> _constructStdTypeResolverBuilder (MapperConfig <?> config ,
1578
+ JsonTypeInfo .Value typeInfo , JavaType baseType ) {
1579
+ return new StdTypeResolverBuilder (typeInfo );
1580
+ }
1581
+
1571
1582
/**
1572
1583
* Helper method for dealing with "no type info" marker; can't be null
1573
1584
* (as it'd be replaced by default typing)
0 commit comments