@@ -80,7 +80,29 @@ public class JacksonAnnotationIntrospector
80
80
* @since 2.7
81
81
*/
82
82
protected transient LRUMap <Class <?>,Boolean > _annotationsInside = new LRUMap <Class <?>,Boolean >(48 , 48 );
83
-
83
+
84
+ /*
85
+ /**********************************************************
86
+ /* Local configuration settings
87
+ /**********************************************************
88
+ */
89
+
90
+ /**
91
+ * See {@link #setConstructorPropertiesImpliesCreator(boolean)} for
92
+ * explanation.
93
+ *<p>
94
+ * Defaults to true.
95
+ *
96
+ * @since 2.7.4
97
+ */
98
+ protected boolean _cfgConstructorPropertiesImpliesCreator = true ;
99
+
100
+ /*
101
+ /**********************************************************
102
+ /* Life-cycle
103
+ /**********************************************************
104
+ */
105
+
84
106
public JacksonAnnotationIntrospector () { }
85
107
86
108
@ Override
@@ -95,6 +117,28 @@ protected Object readResolve() {
95
117
return this ;
96
118
}
97
119
120
+ /*
121
+ /**********************************************************
122
+ /* Configuration
123
+ /**********************************************************
124
+ */
125
+
126
+ /**
127
+ * Method for changing behavior of {@link java.beans.ConstructorProperties}:
128
+ * if set to `true`, existence DOES indicate that the given constructor should
129
+ * be considered a creator; `false` that it should NOT be considered a creator
130
+ * without explicit use of <code>JsonCreator</code> annotation.
131
+ *<p>
132
+ * Default setting is `true`
133
+ *
134
+ * @since 2.7.4
135
+ */
136
+ public JacksonAnnotationIntrospector setConstructorPropertiesImpliesCreator (boolean b )
137
+ {
138
+ _cfgConstructorPropertiesImpliesCreator = b ;
139
+ return this ;
140
+ }
141
+
98
142
/*
99
143
/**********************************************************
100
144
/* General annotation properties
@@ -294,10 +338,9 @@ public VisibilityChecker<?> findAutoDetectVisibility(AnnotatedClass ac,
294
338
*/
295
339
296
340
@ Override
297
- public String findImplicitPropertyName (AnnotatedMember param ) {
298
- // not known by default (until JDK8) for creators; default
299
- //
300
- return null ;
341
+ public String findImplicitPropertyName (AnnotatedMember m ) {
342
+ PropertyName n = _findConstructorName (m );
343
+ return (n == null ) ? null : n .getSimpleName ();
301
344
}
302
345
303
346
@ Override
@@ -866,10 +909,6 @@ public PropertyName findNameForSerialization(Annotated a)
866
909
if (pann != null ) {
867
910
return PropertyName .construct (pann .value ());
868
911
}
869
- PropertyName ctorName = _findConstructorName (a );
870
- if (ctorName != null ) {
871
- return ctorName ;
872
- }
873
912
if (_hasOneOf (a , ANNOTATIONS_TO_INFER_SER )) {
874
913
return PropertyName .USE_DEFAULT ;
875
914
}
@@ -1019,10 +1058,6 @@ public PropertyName findNameForDeserialization(Annotated a)
1019
1058
if (pann != null ) {
1020
1059
return PropertyName .construct (pann .value ());
1021
1060
}
1022
- PropertyName ctorName = _findConstructorName (a );
1023
- if (ctorName != null ) {
1024
- return ctorName ;
1025
- }
1026
1061
if (_hasOneOf (a , ANNOTATIONS_TO_INFER_DESER )) {
1027
1062
return PropertyName .USE_DEFAULT ;
1028
1063
}
@@ -1059,11 +1094,15 @@ public boolean hasCreatorAnnotation(Annotated a)
1059
1094
if (ann != null ) {
1060
1095
return (ann .mode () != JsonCreator .Mode .DISABLED );
1061
1096
}
1062
- if (a instanceof AnnotatedConstructor ) {
1063
- if (_jdk7Helper != null ) {
1064
- Boolean b = _jdk7Helper .hasCreatorAnnotation (a );
1065
- if (b != null ) {
1066
- return b .booleanValue ();
1097
+ // 19-Apr-2016, tatu: As per [databind#1197], [databind#1122] (and some related),
1098
+ // may or may not consider it a creator
1099
+ if (_cfgConstructorPropertiesImpliesCreator ) {
1100
+ if (a instanceof AnnotatedConstructor ) {
1101
+ if (_jdk7Helper != null ) {
1102
+ Boolean b = _jdk7Helper .hasCreatorAnnotation (a );
1103
+ if (b != null ) {
1104
+ return b .booleanValue ();
1105
+ }
1067
1106
}
1068
1107
}
1069
1108
}
0 commit comments