@@ -41,14 +41,33 @@ public void updateClassDescriptor(ClassDescriptor desc) {
4141 desc .fields .add (binding );
4242 }
4343 }
44+ List <Method > allMethods = new ArrayList <Method >();
45+ Class current = desc .clazz ;
46+ while (current != null ) {
47+ allMethods .addAll (Arrays .asList (current .getDeclaredMethods ()));
48+ current = current .getSuperclass ();
49+ }
4450 updateBindings (desc );
45- detectCtorBinding (desc );
46- detectStaticFactoryBinding (desc );
47- detectWrapperBinding (desc );
51+ detectCtor (desc );
52+ detectStaticFactory (desc , allMethods );
53+ detectWrappers (desc , allMethods );
54+ detectUnwrappers (desc , allMethods );
55+ }
56+
57+ private void detectUnwrappers (ClassDescriptor desc , List <Method > allMethods ) {
58+ for (Method method : allMethods ) {
59+ if (Modifier .isStatic (method .getModifiers ())) {
60+ continue ;
61+ }
62+ if (method .getAnnotation (JsonUnwrapper .class ) == null ) {
63+ continue ;
64+ }
65+ desc .unwrappers .add (method );
66+ }
4867 }
4968
50- private void detectWrapperBinding (ClassDescriptor desc ) {
51- for (Method method : desc . clazz . getMethods () ) {
69+ private void detectWrappers (ClassDescriptor desc , List < Method > allMethods ) {
70+ for (Method method : allMethods ) {
5271 if (Modifier .isStatic (method .getModifiers ())) {
5372 continue ;
5473 }
@@ -58,7 +77,6 @@ private void detectWrapperBinding(ClassDescriptor desc) {
5877 Annotation [][] annotations = method .getParameterAnnotations ();
5978 String [] paramNames = getParamNames (method , annotations .length );
6079 WrapperDescriptor setter = new WrapperDescriptor ();
61- setter .methodName = method .getName ();
6280 setter .method = method ;
6381 for (int i = 0 ; i < annotations .length ; i ++) {
6482 Annotation [] paramAnnotations = annotations [i ];
@@ -97,13 +115,7 @@ private Object reflectCall(Object obj, String methodName, Object... args) throws
97115 return method .invoke (obj , args );
98116 }
99117
100- private void detectStaticFactoryBinding (ClassDescriptor desc ) {
101- List <Method > allMethods = new ArrayList <Method >();
102- Class current = desc .clazz ;
103- while (current != null ) {
104- allMethods .addAll (Arrays .asList (current .getDeclaredMethods ()));
105- current = current .getSuperclass ();
106- }
118+ private void detectStaticFactory (ClassDescriptor desc , List <Method > allMethods ) {
107119 for (Method method : allMethods ) {
108120 if (!Modifier .isStatic (method .getModifiers ())) {
109121 continue ;
@@ -136,7 +148,7 @@ private void detectStaticFactoryBinding(ClassDescriptor desc) {
136148 }
137149 }
138150
139- private void detectCtorBinding (ClassDescriptor desc ) {
151+ private void detectCtor (ClassDescriptor desc ) {
140152 for (Constructor ctor : desc .clazz .getDeclaredConstructors ()) {
141153 JsonCreator jsonCreator = getJsonCreator (ctor .getAnnotations ());
142154 if (jsonCreator == null ) {
0 commit comments