@@ -62,7 +62,7 @@ private void detectUnwrappers(ClassDescriptor desc, List<Method> allMethods) {
6262 if (method .getAnnotation (JsonUnwrapper .class ) == null ) {
6363 continue ;
6464 }
65- desc .unwrappers .add (method );
65+ desc .unWrappers .add (method );
6666 }
6767 }
6868
@@ -83,10 +83,7 @@ private void detectWrappers(ClassDescriptor desc, List<Method> allMethods) {
8383 Binding binding = new Binding (desc .clazz , desc .lookup , method .getGenericParameterTypes ()[i ]);
8484 JsonProperty jsonProperty = getJsonProperty (paramAnnotations );
8585 if (jsonProperty != null ) {
86- binding .name = jsonProperty .value ();
87- if (jsonProperty .required ()) {
88- binding .asMissingWhenNotPresent = true ;
89- }
86+ updateBindingWithJsonProperty (binding , jsonProperty );
9087 }
9188 if (binding .name == null || binding .name .length () == 0 ) {
9289 binding .name = paramNames [i ];
@@ -134,10 +131,7 @@ private void detectStaticFactory(ClassDescriptor desc, List<Method> allMethods)
134131 JsonProperty jsonProperty = getJsonProperty (paramAnnotations );
135132 Binding binding = new Binding (desc .clazz , desc .lookup , method .getGenericParameterTypes ()[i ]);
136133 if (jsonProperty != null ) {
137- binding .name = jsonProperty .value ();
138- if (jsonProperty .required ()) {
139- binding .asMissingWhenNotPresent = true ;
140- }
134+ updateBindingWithJsonProperty (binding , jsonProperty );
141135 }
142136 if (binding .name == null || binding .name .length () == 0 ) {
143137 binding .name = paramNames [i ];
@@ -164,10 +158,7 @@ private void detectCtor(ClassDescriptor desc) {
164158 JsonProperty jsonProperty = getJsonProperty (paramAnnotations );
165159 Binding binding = new Binding (desc .clazz , desc .lookup , ctor .getGenericParameterTypes ()[i ]);
166160 if (jsonProperty != null ) {
167- binding .name = jsonProperty .value ();
168- if (jsonProperty .required ()) {
169- binding .asMissingWhenNotPresent = true ;
170- }
161+ updateBindingWithJsonProperty (binding , jsonProperty );
171162 }
172163 if (binding .name == null || binding .name .length () == 0 ) {
173164 binding .name = paramNames [i ];
@@ -187,38 +178,7 @@ private void updateBindings(ClassDescriptor desc) {
187178 }
188179 JsonProperty jsonProperty = getJsonProperty (binding .annotations );
189180 if (jsonProperty != null ) {
190- String altName = jsonProperty .value ();
191- if (!altName .isEmpty ()) {
192- binding .name = altName ;
193- binding .fromNames = new String []{altName };
194- }
195- if (jsonProperty .from ().length > 0 ) {
196- binding .fromNames = jsonProperty .from ();
197- }
198- if (jsonProperty .to ().length > 0 ) {
199- binding .toNames = jsonProperty .to ();
200- }
201- if (jsonProperty .required ()) {
202- binding .asMissingWhenNotPresent = true ;
203- }
204- if (jsonProperty .decoder () != Decoder .class ) {
205- try {
206- binding .decoder = jsonProperty .decoder ().newInstance ();
207- } catch (Exception e ) {
208- throw new JsonException (e );
209- }
210- }
211- if (jsonProperty .encoder () != Encoder .class ) {
212- try {
213- binding .encoder = jsonProperty .encoder ().newInstance ();
214- } catch (Exception e ) {
215- throw new JsonException (e );
216- }
217- }
218- if (jsonProperty .implementation () != Object .class ) {
219- binding .valueType = ParameterizedTypeImpl .useImpl (binding .valueType , jsonProperty .implementation ());
220- binding .valueTypeLiteral = TypeLiteral .create (binding .valueType );
221- }
181+ updateBindingWithJsonProperty (binding , jsonProperty );
222182 }
223183 if (getAnnotation (binding .annotations , JsonMissingProperties .class ) != null ) {
224184 // this binding will not bind from json
@@ -235,6 +195,42 @@ private void updateBindings(ClassDescriptor desc) {
235195 }
236196 }
237197
198+ private void updateBindingWithJsonProperty (Binding binding , JsonProperty jsonProperty ) {
199+ binding .asMissingWhenNotPresent = jsonProperty .required ();
200+ binding .isNullable = jsonProperty .nullable ();
201+ binding .isCollectionValueNullable = jsonProperty .collectionValueNullable ();
202+ binding .shouldOmitNull = jsonProperty .omitNull ();
203+ String altName = jsonProperty .value ();
204+ if (!altName .isEmpty ()) {
205+ binding .name = altName ;
206+ binding .fromNames = new String []{altName };
207+ }
208+ if (jsonProperty .from ().length > 0 ) {
209+ binding .fromNames = jsonProperty .from ();
210+ }
211+ if (jsonProperty .to ().length > 0 ) {
212+ binding .toNames = jsonProperty .to ();
213+ }
214+ if (jsonProperty .decoder () != Decoder .class ) {
215+ try {
216+ binding .decoder = jsonProperty .decoder ().newInstance ();
217+ } catch (Exception e ) {
218+ throw new JsonException (e );
219+ }
220+ }
221+ if (jsonProperty .encoder () != Encoder .class ) {
222+ try {
223+ binding .encoder = jsonProperty .encoder ().newInstance ();
224+ } catch (Exception e ) {
225+ throw new JsonException (e );
226+ }
227+ }
228+ if (jsonProperty .implementation () != Object .class ) {
229+ binding .valueType = ParameterizedTypeImpl .useImpl (binding .valueType , jsonProperty .implementation ());
230+ binding .valueTypeLiteral = TypeLiteral .create (binding .valueType );
231+ }
232+ }
233+
238234 protected JsonCreator getJsonCreator (Annotation [] annotations ) {
239235 return getAnnotation (annotations , JsonCreator .class );
240236 }
0 commit comments