@@ -17,16 +17,18 @@ public class PotentialCreator
17
17
{
18
18
private static final PropertyName [] NO_NAMES = new PropertyName [0 ];
19
19
20
- private final AnnotatedWithParams creator ;
20
+ private final AnnotatedWithParams _creator ;
21
+
22
+ private final boolean _isAnnotated ;
21
23
22
24
/**
23
25
* Declared Mode of the creator, if explicitly annotated; {@code null} otherwise
24
26
*/
25
- private JsonCreator .Mode creatorMode ;
27
+ private JsonCreator .Mode _creatorMode ;
26
28
27
- private PropertyName [] implicitParamNames ;
29
+ private PropertyName [] _implicitParamNames ;
28
30
29
- private PropertyName [] explicitParamNames ;
31
+ private PropertyName [] _explicitParamNames ;
30
32
31
33
/**
32
34
* Parameter definitions if (and only if) this represents a
@@ -37,8 +39,9 @@ public class PotentialCreator
37
39
public PotentialCreator (AnnotatedWithParams cr ,
38
40
JsonCreator .Mode cm )
39
41
{
40
- creator = cr ;
41
- creatorMode = cm ;
42
+ _creator = cr ;
43
+ _isAnnotated = (cm != null );
44
+ _creatorMode = (cm == null ) ? JsonCreator .Mode .DEFAULT : cm ;
42
45
}
43
46
44
47
/**
@@ -51,7 +54,7 @@ public PotentialCreator(AnnotatedWithParams cr,
51
54
* @return This creator instance
52
55
*/
53
56
public PotentialCreator overrideMode (JsonCreator .Mode mode ) {
54
- creatorMode = mode ;
57
+ _creatorMode = mode ;
55
58
return this ;
56
59
}
57
60
@@ -68,30 +71,30 @@ public void assignPropertyDefs(List<? extends BeanPropertyDefinition> propertyDe
68
71
69
72
public PotentialCreator introspectParamNames (MapperConfig <?> config )
70
73
{
71
- if (implicitParamNames != null ) {
74
+ if (_implicitParamNames != null ) {
72
75
return this ;
73
76
}
74
- final int paramCount = creator .getParameterCount ();
77
+ final int paramCount = _creator .getParameterCount ();
75
78
76
79
if (paramCount == 0 ) {
77
- implicitParamNames = explicitParamNames = NO_NAMES ;
80
+ _implicitParamNames = _explicitParamNames = NO_NAMES ;
78
81
return this ;
79
82
}
80
83
81
- explicitParamNames = new PropertyName [paramCount ];
82
- implicitParamNames = new PropertyName [paramCount ];
84
+ _explicitParamNames = new PropertyName [paramCount ];
85
+ _implicitParamNames = new PropertyName [paramCount ];
83
86
84
87
final AnnotationIntrospector intr = config .getAnnotationIntrospector ();
85
88
for (int i = 0 ; i < paramCount ; ++i ) {
86
- AnnotatedParameter param = creator .getParameter (i );
89
+ AnnotatedParameter param = _creator .getParameter (i );
87
90
88
91
String rawImplName = intr .findImplicitPropertyName (param );
89
92
if (rawImplName != null && !rawImplName .isEmpty ()) {
90
- implicitParamNames [i ] = PropertyName .construct (rawImplName );
93
+ _implicitParamNames [i ] = PropertyName .construct (rawImplName );
91
94
}
92
95
PropertyName explName = intr .findNameForDeserialization (param );
93
96
if (explName != null && !explName .isEmpty ()) {
94
- explicitParamNames [i ] = explName ;
97
+ _explicitParamNames [i ] = explName ;
95
98
}
96
99
}
97
100
return this ;
@@ -104,25 +107,25 @@ public PotentialCreator introspectParamNames(MapperConfig<?> config)
104
107
public PotentialCreator introspectParamNames (MapperConfig <?> config ,
105
108
PropertyName [] implicits )
106
109
{
107
- if (implicitParamNames != null ) {
110
+ if (_implicitParamNames != null ) {
108
111
return this ;
109
112
}
110
- final int paramCount = creator .getParameterCount ();
113
+ final int paramCount = _creator .getParameterCount ();
111
114
if (paramCount == 0 ) {
112
- implicitParamNames = explicitParamNames = NO_NAMES ;
115
+ _implicitParamNames = _explicitParamNames = NO_NAMES ;
113
116
return this ;
114
117
}
115
118
116
- explicitParamNames = new PropertyName [paramCount ];
117
- implicitParamNames = implicits ;
119
+ _explicitParamNames = new PropertyName [paramCount ];
120
+ _implicitParamNames = implicits ;
118
121
119
122
final AnnotationIntrospector intr = config .getAnnotationIntrospector ();
120
123
for (int i = 0 ; i < paramCount ; ++i ) {
121
- AnnotatedParameter param = creator .getParameter (i );
124
+ AnnotatedParameter param = _creator .getParameter (i );
122
125
123
126
PropertyName explName = intr .findNameForDeserialization (param );
124
127
if (explName != null && !explName .isEmpty ()) {
125
- explicitParamNames [i ] = explName ;
128
+ _explicitParamNames [i ] = explName ;
126
129
}
127
130
}
128
131
return this ;
@@ -134,57 +137,61 @@ public PotentialCreator introspectParamNames(MapperConfig<?> config,
134
137
/**********************************************************************
135
138
*/
136
139
140
+ public boolean isAnnotated () {
141
+ return _isAnnotated ;
142
+ }
143
+
137
144
public AnnotatedWithParams creator () {
138
- return creator ;
145
+ return _creator ;
139
146
}
140
147
141
148
/**
142
149
* @return Mode declared for this Creator by annotation, if any; {@code null}
143
150
* if not annotated
144
151
*/
145
152
public JsonCreator .Mode creatorMode () {
146
- return creatorMode ;
153
+ return _creatorMode ;
147
154
}
148
155
149
156
/**
150
157
* Same as {@link #creatorMode()} except that if {@code null} was to be
151
158
* returned, will instead return {@code JsonCreator.Mode.DEFAULT}/
152
159
*/
153
160
public JsonCreator .Mode creatorModeOrDefault () {
154
- if (creatorMode == null ) {
161
+ if (_creatorMode == null ) {
155
162
return JsonCreator .Mode .DEFAULT ;
156
163
}
157
- return creatorMode ;
164
+ return _creatorMode ;
158
165
}
159
166
160
167
public int paramCount () {
161
- return creator .getParameterCount ();
168
+ return _creator .getParameterCount ();
162
169
}
163
170
164
171
public AnnotatedParameter param (int ix ) {
165
- return creator .getParameter (ix );
172
+ return _creator .getParameter (ix );
166
173
}
167
174
168
175
public boolean hasExplicitNames () {
169
- for (int i = 0 , end = explicitParamNames .length ; i < end ; ++i ) {
170
- if (explicitParamNames [i ] != null ) {
176
+ for (int i = 0 , end = _explicitParamNames .length ; i < end ; ++i ) {
177
+ if (_explicitParamNames [i ] != null ) {
171
178
return true ;
172
179
}
173
180
}
174
181
return false ;
175
182
}
176
183
177
184
public boolean hasNameFor (int ix ) {
178
- return (explicitParamNames [ix ] != null )
179
- || (implicitParamNames [ix ] != null );
185
+ return (_explicitParamNames [ix ] != null )
186
+ || (_implicitParamNames [ix ] != null );
180
187
}
181
188
182
189
public boolean hasNameOrInjectForAllParams (MapperConfig <?> config )
183
190
{
184
191
final AnnotationIntrospector intr = config .getAnnotationIntrospector ();
185
- for (int i = 0 , end = implicitParamNames .length ; i < end ; ++i ) {
192
+ for (int i = 0 , end = _implicitParamNames .length ; i < end ; ++i ) {
186
193
if (!hasNameFor (i )) {
187
- if (intr == null || intr .findInjectableValue (creator .getParameter (i )) == null ) {
194
+ if (intr == null || intr .findInjectableValue (_creator .getParameter (i )) == null ) {
188
195
return false ;
189
196
}
190
197
}
@@ -193,15 +200,15 @@ public boolean hasNameOrInjectForAllParams(MapperConfig<?> config)
193
200
}
194
201
195
202
public PropertyName explicitName (int ix ) {
196
- return explicitParamNames [ix ];
203
+ return _explicitParamNames [ix ];
197
204
}
198
205
199
206
public PropertyName implicitName (int ix ) {
200
- return implicitParamNames [ix ];
207
+ return _implicitParamNames [ix ];
201
208
}
202
209
203
210
public String implicitNameSimple (int ix ) {
204
- PropertyName pn = implicitParamNames [ix ];
211
+ PropertyName pn = _implicitParamNames [ix ];
205
212
return (pn == null ) ? null : pn .getSimpleName ();
206
213
}
207
214
@@ -221,7 +228,7 @@ public BeanPropertyDefinition[] propertyDefs() {
221
228
// For troubleshooting
222
229
@ Override
223
230
public String toString () {
224
- return "(mode=" +creatorMode +")" +creator ;
231
+ return "(mode=" +_creatorMode +")" +_creator ;
225
232
}
226
233
}
227
234
0 commit comments