I'm trying to initialize a class with Reflection and a Map (This due a more complex requirement, I just isolated the example)
public class ParentDto {
private String field1;
private BigDecimal field2;
private List<AClass> listField3;
}
I created a map to set values for the first 2 fields with a generic value Map
public static final Map<String, Object> INITIALIZER = Map.ofEntries(
Map.entry("field1", "String"),
Map.entry("field2", new BigDecimal("23.43")
However, if i try to do the same for the list it will fail. It makes sense since Object is not a Base Class for List. My question is: Is there any way I can add
Map.entry("listField3", List.of("e1","e2"))
into my static map? A superclass that have in common both Objects and List
Aucun commentaire:
Enregistrer un commentaire