POJOs

The following methods are provided for accessing POJO values:

In theory, any {@doc PojoCategories parsable} POJO type can be represented as a config value. However in practice, we're typically talking about the following:

An example of an object convertible from a String was already shown in an example above. In that case, it was a URL which has a public constructor that takes in a String:

# A POJO key4 = http://bar

// Read values from section #1 URL key4 = config.getObject("Section1/key4", URL.class);

Beans are represented as {@doc SimplifiedJson Simplified JSON} by default:

// Contact information [ContactInfo] address = { 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.getObject("ContactInfo/address", Address.class);

The format for beans depends on the serializer and parser registered on the Config which is defined in the builder via the following methods:

The default parser can also be overridden on the following getters: