@@ -103,33 +103,32 @@ public static AbstractDeserializer constructForNonPOJO(BeanDescription beanDesc)
103
103
public JsonDeserializer <?> createContextual (DeserializationContext ctxt ,
104
104
BeanProperty property ) throws JsonMappingException
105
105
{
106
- // First: may have an override for Object Id:
107
106
final AnnotationIntrospector intr = ctxt .getAnnotationIntrospector ();
108
- final AnnotatedMember accessor = (property == null || intr == null )
109
- ? null : property .getMember ();
110
- if (accessor != null && intr != null ) {
111
- ObjectIdInfo objectIdInfo = intr .findObjectIdInfo (accessor );
112
- if (objectIdInfo != null ) { // some code duplication here as well (from BeanDeserializerFactory)
113
- // 2.1: allow modifications by "id ref" annotations as well:
114
- objectIdInfo = intr .findObjectReferenceInfo (accessor , objectIdInfo );
115
-
116
- Class <?> implClass = objectIdInfo .getGeneratorType ();
117
- // 02-May-2017, tatu: Alas, properties are NOT available for abstract classes; can not
118
- // support this particular type
119
- if (implClass == ObjectIdGenerators .PropertyGenerator .class ) {
120
- ctxt .reportMappingException (
107
+ if (property != null && intr != null ) {
108
+ final AnnotatedMember accessor = property .getMember ();
109
+ if (accessor != null ) {
110
+ ObjectIdInfo objectIdInfo = intr .findObjectIdInfo (accessor );
111
+ if (objectIdInfo != null ) { // some code duplication here as well (from BeanDeserializerFactory)
112
+ // 2.1: allow modifications by "id ref" annotations as well:
113
+ objectIdInfo = intr .findObjectReferenceInfo (accessor , objectIdInfo );
114
+ Class <?> implClass = objectIdInfo .getGeneratorType ();
115
+ // 02-May-2017, tatu: Alas, properties are NOT available for abstract classes; can not
116
+ // support this particular type. Yet.
117
+ if (implClass == ObjectIdGenerators .PropertyGenerator .class ) {
118
+ ctxt .reportBadDefinition (_baseType , String .format (
121
119
"Invalid Object Id definition for abstract type %s: can not use `PropertyGenerator` on polymorphic types using property annotation" ,
122
- handledType ().getName ());
120
+ handledType ().getName ()));
121
+ }
122
+ ObjectIdResolver resolver = ctxt .objectIdResolverInstance (accessor , objectIdInfo );
123
+ JavaType type = ctxt .constructType (implClass );
124
+ JavaType idType = ctxt .getTypeFactory ().findTypeParameters (type , ObjectIdGenerator .class )[0 ];
125
+ SettableBeanProperty idProp = null ;
126
+ ObjectIdGenerator <?> idGen = ctxt .objectIdGeneratorInstance (accessor , objectIdInfo );
127
+ JsonDeserializer <?> deser = ctxt .findRootValueDeserializer (idType );
128
+ ObjectIdReader oir = ObjectIdReader .construct (idType , objectIdInfo .getPropertyName (),
129
+ idGen , deser , idProp , resolver );
130
+ return new AbstractDeserializer (this , oir );
123
131
}
124
- ObjectIdResolver resolver = ctxt .objectIdResolverInstance (accessor , objectIdInfo );
125
- JavaType type = ctxt .constructType (implClass );
126
- JavaType idType = ctxt .getTypeFactory ().findTypeParameters (type , ObjectIdGenerator .class )[0 ];
127
- SettableBeanProperty idProp = null ;
128
- ObjectIdGenerator <?> idGen = ctxt .objectIdGeneratorInstance (accessor , objectIdInfo );
129
- JsonDeserializer <?> deser = ctxt .findRootValueDeserializer (idType );
130
- ObjectIdReader oir = ObjectIdReader .construct (idType , objectIdInfo .getPropertyName (),
131
- idGen , deser , idProp , resolver );
132
- return new AbstractDeserializer (this , oir );
133
132
}
134
133
}
135
134
// either way, need to resolve serializer:
@@ -207,10 +206,8 @@ public Object deserializeWithType(JsonParser p, DeserializationContext ctxt,
207
206
&& _objectIdReader .isValidReferencePropertyName (p .getCurrentName (), p )) {
208
207
return _deserializeFromObjectId (p , ctxt );
209
208
}
210
-
211
209
}
212
210
}
213
-
214
211
// First: support "natural" values (which are always serialized without type info!)
215
212
Object result = _deserializeIfNatural (p , ctxt );
216
213
if (result != null ) {
@@ -236,7 +233,7 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt)
236
233
/* Internal methods
237
234
/**********************************************************
238
235
*/
239
-
236
+
240
237
protected Object _deserializeIfNatural (JsonParser p , DeserializationContext ctxt ) throws IOException
241
238
{
242
239
/* There is a chance we might be "natural" types
0 commit comments