@@ -42,6 +42,7 @@ Use mutable classes with fields that can be set reflectively. Field visibility c
4242- Fields should be non-primitive boxed/object types (` Integer ` , not ` int ` ).
4343- Value objects can validate with a single-arg constructor.
4444- ` Optional<T> ` , ` List<T> ` , ` Set<T> ` , and ` Map<K,V> ` are supported.
45+ - Nested generic combinations are supported (for example ` GenericBox<List<GenericItem<String>>> ` , ` Map<StringConstructedGenericKey<Integer>, List<String>> ` ).
4546- Enums are parsed from string names.
4647- Expose values however you prefer (public fields or getters on private fields).
4748
@@ -119,6 +120,30 @@ AppConfig xmlCfg = new XmlDeserializer().deserialize(
119120);
120121```
121122
123+ ## Nested generics example
124+
125+ ``` java
126+ import java.util.List ;
127+ import java.util.Map ;
128+
129+ class GenericBox <T> { public T value; }
130+ class GenericItem <T> { public T payload; }
131+ class StringConstructedGenericKey <T> {
132+ public final String value;
133+ public StringConstructedGenericKey (String value ) { this . value = value; }
134+ }
135+
136+ class GenericConfig {
137+ public GenericBox<List<GenericItem<String > > > foo;
138+ public Map<StringConstructedGenericKey<Integer > , List<String > > values;
139+ }
140+
141+ GenericConfig cfg = new JsonDeserializer (). deserialize(
142+ " {\" foo\" :{\" value\" :[{\" payload\" :\" a\" }]},\" values\" :{\" k1\" :[\" x\" ,\" y\" ]}}" ,
143+ GenericConfig . class
144+ );
145+ ```
146+
122147## Validation and errors
123148
124149Object mapping and validation are done in one pass. Field errors are collected, then one ` ConfigDeserializationException ` is thrown with all errors.
0 commit comments