You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, if you want to add other info like a bean list called "City", it won't be serialized:
@Getter@Setter// LombokpublicclassCityimplementsParameterizedType {
privatestaticfinalType[] TYPE_ARGUMENTS = {
String.class, // city typeInteger.TYPE, // population type
};
privateStringname;
privateintpopulation;
...
}
@Getter@Setter// LombokpublicclassCountryimplementsParameterizedType {
privatestaticfinalType[] TYPE_ARGUMENTS = {
String.class, // name typeInteger.TYPE, // total population typeCity[].class, // the city array type
};
privateStringname;
privateinttotalPopulation;
privateCity[] cities;
...
}
The YAML result will be:
country.list:
- name: United StatestotalPopulation: 331000000cities: {}
But what I want is:
country.list:
- name: United StatestotalPopulation: 331000000cities:
- name: New Yorkpopulation: 8400000
- name: Las Vegaspopulation: 646700
A solution (?)
Maybe, define a BeanListProperty that extends ListPropery and grants an easy way to add beans without map field types.
The text was updated successfully, but these errors were encountered:
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":
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 #354 (comment)
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.
The text was updated successfully, but these errors were encountered: