1
1
package com .fasterxml .jackson .module .paranamer ;
2
2
3
- import java .lang .reflect .AccessibleObject ;
4
- import java .lang .reflect .AnnotatedElement ;
5
-
6
3
import com .fasterxml .jackson .databind .*;
7
4
import com .fasterxml .jackson .databind .introspect .Annotated ;
8
5
import com .fasterxml .jackson .databind .introspect .AnnotatedMember ;
@@ -21,16 +18,27 @@ public class ParanamerAnnotationIntrospector
21
18
{
22
19
private static final long serialVersionUID = 1 ;
23
20
24
- protected final Paranamer _paranamer ;
21
+ /**
22
+ * Wrapper used to encapsulate actual Paranamer call, to allow serialization
23
+ * of this introspector
24
+ */
25
+ protected final SerializableParanamer _paranamer ;
25
26
26
27
public ParanamerAnnotationIntrospector () {
27
- this (new CachingParanamer ( new BytecodeReadingParanamer () ));
28
+ this (new SerializableParanamer ( ));
28
29
}
29
30
30
- public ParanamerAnnotationIntrospector (Paranamer pn ) {
31
+ /**
32
+ * @since 2.7.6
33
+ */
34
+ public ParanamerAnnotationIntrospector (SerializableParanamer pn ) {
31
35
_paranamer = pn ;
32
36
}
33
37
38
+ public ParanamerAnnotationIntrospector (Paranamer pn ) {
39
+ this (new SerializableParanamer (pn ));
40
+ }
41
+
34
42
@ Override
35
43
public PropertyName findNameForDeserialization (Annotated a )
36
44
{
@@ -39,10 +47,13 @@ public PropertyName findNameForDeserialization(Annotated a)
39
47
* in {@link #findParameterSourceName(AnnotatedParameter)}.
40
48
*/
41
49
/*
42
- if (a instanceof AnnotatedParameter) {
43
- String rawName = _findParaName((AnnotatedParameter) a);
44
- if (rawName != null) {
45
- return new PropertyName(rawName);
50
+ PropertyName name = super.findNameForDeserialization(a);
51
+ if (name == null) {
52
+ if (a instanceof AnnotatedParameter) {
53
+ String rawName _paranamer.findParameterName((AnnotatedParameter) a);
54
+ if (rawName != null) {
55
+ return new PropertyName(rawName);
56
+ }
46
57
}
47
58
}
48
59
*/
@@ -53,26 +64,7 @@ public PropertyName findNameForDeserialization(Annotated a)
53
64
@ Override
54
65
public String findImplicitPropertyName (AnnotatedMember param ) {
55
66
if (param instanceof AnnotatedParameter ) {
56
- return _findParaName ((AnnotatedParameter ) param );
57
- }
58
- return null ;
59
- }
60
-
61
- /*
62
- /**********************************************************
63
- /* Internal methods
64
- /**********************************************************
65
- */
66
-
67
- protected String _findParaName (AnnotatedParameter param )
68
- {
69
- int index = param .getIndex ();
70
- AnnotatedElement ctor = param .getOwner ().getAnnotated ();
71
- String [] names = _paranamer .lookupParameterNames ((AccessibleObject ) ctor , false );
72
- if (names != null ) {
73
- if (index < names .length ) {
74
- return names [index ];
75
- }
67
+ return _paranamer .findParameterName ((AnnotatedParameter ) param );
76
68
}
77
69
return null ;
78
70
}
0 commit comments