yamlbeans icon indicating copy to clipboard operation
yamlbeans copied to clipboard

request for automatic detection of parameterized List's

Open The-Alchemist opened this issue 10 years ago • 2 comments

If we have:

public class Machines {
    public List<Machine> machines;
}

public class Machine {
    public String machine_used;
    public List<Measurement> measurements;
}

I have to say:

        yamlConfig.setPropertyElementType(Machines.class, "machines", Machine.class);
        yamlConfig.setPropertyElementType(Machine.class, "measurements", Measurement.class);

Couldn't yamlbeans conceivably use the generic parameter of the List as a safe default?

I can submit a pull request, if it has a decent chance of getting accepted. :)

The-Alchemist avatar Apr 01 '15 17:04 The-Alchemist

Yes, it could. A PR would be merged if the changes are relatively small. You can see how JsonBeans does it. Supporting only a single generic type like that is reasonable, I don't think it's worth the complexity to do more.

NathanSweet avatar Apr 01 '15 17:04 NathanSweet

I would certainly vote for that feature!

daimonion avatar Jan 22 '16 09:01 daimonion