@@ -169,6 +169,30 @@ public MyType490(
169169 }
170170 }
171171
172+ // [dataformat-xml#767]
173+ @ JsonTypeInfo (
174+ use = JsonTypeInfo .Id .NAME ,
175+ include = JsonTypeInfo .As .EXISTING_PROPERTY ,
176+ property = "type" )
177+ @ JsonSubTypes ({
178+ @ JsonSubTypes .Type (value = MyType767 .class , name = "myType" ),
179+ })
180+ interface IMyType767 { }
181+
182+ static class MyType767 implements IMyType767 {
183+ public final String stringValue ;
184+ public final String type = "myType" ;
185+ public final Collection <String > typeNames ;
186+
187+ @ JsonCreator
188+ public MyType767 (
189+ @ JsonProperty ("stringValue" ) String stringValue ,
190+ @ JsonProperty ("typeNames" ) Collection <String > typeNames ) {
191+ this .stringValue = stringValue ;
192+ this .typeNames = typeNames ;
193+ }
194+ }
195+
172196 // [dataformat-xml#567]
173197 @ JsonRootName ("wrapper" )
174198 static class Wrapper567 extends Base567 {
@@ -321,6 +345,26 @@ public void testPolymorphicUnwrappedList490() throws Exception
321345 assertEquals (Arrays .asList ("type1" , "type2" ), typedResult .typeNames );
322346 }
323347
348+ // [dataformat-xml#767]: Like #490, but with EXISTING_PROPERTY
349+ @ Test
350+ public void testPolymorphicUnwrappedListExistingProperty767 () throws Exception
351+ {
352+ XmlMapper xmlMapper = XmlMapper .builder ()
353+ .defaultUseWrapper (false ).build ();
354+
355+ List <String > typeNames = new ArrayList <>();
356+ typeNames .add ("type1" );
357+ typeNames .add ("type2" );
358+ MyType767 input = new MyType767 ("hello" , typeNames );
359+ String doc = xmlMapper .writeValueAsString (input );
360+ IMyType767 result = xmlMapper .readValue (doc , IMyType767 .class );
361+
362+ assertNotNull (result );
363+ assertEquals (MyType767 .class , result .getClass ());
364+ MyType767 typedResult = (MyType767 ) result ;
365+ assertEquals (Arrays .asList ("type1" , "type2" ), typedResult .typeNames );
366+ }
367+
324368 // [dataformat-xml#567]
325369 @ Test
326370 public void testPolyList567_3items () throws Exception {
0 commit comments