Section Beans
Config files can also be used to directly populate beans using
{@link oaj.config.Config#getSectionAsBean(String,Class,boolean)}.
// Example config file
[MyAddress]
street = 123 Main Street
city = Anywhere
state = NY
zip = 12345
// Example bean
public class Address {
public String street, city;
public StateEnum state;
public int zip;
}
// Example usage
Config c = Config.create("MyConfig.cfg").build();
Address myAddress = c.getSectionAsBean("MyAddress", Address.class);
Like maps, beans created this way are snapshot copies of the section at the time of the method call.