@@ -55,14 +55,18 @@ public String toString() {
55
55
}
56
56
}
57
57
58
- static class DelegatingCanonicalFindingIntrospector extends ImplicitNameIntrospector
58
+ static class PrimaryCreatorFindingIntrospector extends ImplicitNameIntrospector
59
59
{
60
60
private static final long serialVersionUID = 1L ;
61
61
62
- private final Class <?> _argType ;
62
+ private final Class <?>[] _argTypes ;
63
63
64
- public DelegatingCanonicalFindingIntrospector (Class <?> argType ) {
65
- _argType = argType ;
64
+ private JsonCreator .Mode _mode ;
65
+
66
+ public PrimaryCreatorFindingIntrospector (JsonCreator .Mode mode ,
67
+ Class <?>... argTypes ) {
68
+ _mode = mode ;
69
+ _argTypes = argTypes ;
66
70
}
67
71
68
72
@ Override
@@ -78,12 +82,20 @@ public PotentialCreator findPrimaryCreator(MapperConfig<?> config,
78
82
System .err .println ("findCanonicalCreator DONE for: " +valueClass .getRawType ());
79
83
List <PotentialCreator > combo = new ArrayList <>(declaredConstructors );
80
84
combo .addAll (declaredFactories );
85
+ final int argCount = _argTypes .length ;
81
86
for (PotentialCreator ctor : combo ) {
82
- if (ctor .paramCount () == 1
83
- && _argType == ctor .param (0 ).getRawType ()) {
87
+ if (ctor .paramCount () == argCount ) {
88
+ int i = 0 ;
89
+ for (; i < argCount ; ++i ) {
90
+ if (_argTypes [i ] != ctor .param (i ).getRawType ()) {
91
+ break ;
92
+ }
93
+ }
94
+ if (i == argCount ) {
84
95
System .err .println ("MATCH! " +ctor );
85
- ctor .overrideMode (JsonCreator .Mode .DELEGATING );
86
- return ctor ;
96
+ ctor .overrideMode (_mode );
97
+ return ctor ;
98
+ }
87
99
}
88
100
}
89
101
System .err .println ("No MATCH! " );
@@ -102,7 +114,8 @@ public PotentialCreator findPrimaryCreator(MapperConfig<?> config,
102
114
public void testCanonicalConstructorPropertiesCreator() throws Exception
103
115
{
104
116
assertEquals(POJO4584.factoryString("List[0]"),
105
- readerWith(new DelegatingCanonicalFindingIntrospector(List.class))
117
+ readerWith(new PrimaryCreatorFindingIntrospector(JsonCreator.Mode.PROPERTIES,
118
+ List.class))
106
119
.readValue(a2q("{'x':[ ]}")));
107
120
}
108
121
*/
@@ -116,24 +129,27 @@ public void testCanonicalConstructorPropertiesCreator() throws Exception
116
129
@ Test
117
130
public void testCanonicalConstructorDelegatingIntCreator () throws Exception
118
131
{
119
- assertEquals (POJO4584 .factoryString ("List[3]" ),
120
- readerWith (new DelegatingCanonicalFindingIntrospector (List .class ))
121
- .readValue (a2q ("[1, 2, 3]" )));
132
+ assertEquals (POJO4584 .factoryString ("int[42]" ),
133
+ readerWith (new PrimaryCreatorFindingIntrospector (JsonCreator .Mode .DELEGATING ,
134
+ Integer .TYPE ))
135
+ .readValue (a2q ("42" )));
122
136
}
123
137
124
138
@ Test
125
139
public void testCanonicalConstructorDelegatingListCreator () throws Exception
126
140
{
127
141
assertEquals (POJO4584 .factoryString ("List[3]" ),
128
- readerWith (new DelegatingCanonicalFindingIntrospector (List .class ))
142
+ readerWith (new PrimaryCreatorFindingIntrospector (JsonCreator .Mode .DELEGATING ,
143
+ List .class ))
129
144
.readValue (a2q ("[1, 2, 3]" )));
130
145
}
131
146
132
147
@ Test
133
148
public void testCanonicalConstructorDelegatingArrayCreator () throws Exception
134
149
{
135
150
assertEquals (POJO4584 .factoryString ("Array[1]" ),
136
- readerWith (new DelegatingCanonicalFindingIntrospector (Object [].class ))
151
+ readerWith (new PrimaryCreatorFindingIntrospector (JsonCreator .Mode .DELEGATING ,
152
+ Object [].class ))
137
153
.readValue (a2q ("[true]" )));
138
154
}
139
155
0 commit comments