Open gamerover98 opened 10 months ago
After conducting various tests, I have come to a conclusion. It is incorrect to serialize an array of Beans using the PropertyBuilder.ArrayPropertyBuilder(...)
method. Instead, it is much easier to create a Bean class that encapsulates everything. Let me explain further by referring to the example of "Country":
The World Bean class:
@Getter @Setter
public class World {
private List<Country> countries;
}
The property:
public static final Property<World> WORLD =
newBeanProperty(World.class, "world", new World());
This is probably the best solution since YAML sequences can look a bit weird without a property.
In ConfigMe 2.0, arrays or lists of a bean property type will become easier to maintain as ListPropertyType
and ArrayPropertyType
are based on an entry property type, which could be a bean property type (#230). I don't have any simple tests using a bean property so I might use this issue for adding some. Thanks!
Reminder not to implement ParameterizedType by yourself, as detailed in https://github.com/AuthMe/ConfigMe/issues/354#issuecomment-1681889202
The problem It is not easy to create a list or array of BeanProperty. At the moment, I have found this solution:
Now, if you want to add other info like a bean list called "City", it won't be serialized:
The YAML result will be:
But what I want is:
A solution (?) Maybe, define a BeanListProperty that extends ListPropery and grants an easy way to add beans without map field types.