Section Beans

Config files can also be used to directly populate beans using {@link oaj.config.Config#getSectionAsBean(String,Class,boolean)}.

##### Example:

// 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 config = Config.create("MyConfig.cfg").build(); Address myAddress = config.getSectionAsBean("MyAddress", Address.class);

Like maps, beans created this way are snapshot copies of the section at the time of the method call.