Recently i stumbled across the Owner Library(owner.aeonbits.org ). Using this small piece of technology, usage of Java property files can be reinvented! Now we can access properties using a refactoring safe interface the following way:

public interface ServerConfig extends Config {
    @Key("server.http.port")
    int port();


    @Key("server.host.name")
    String hostname();


    @Key("server.max.threads");
    @DefaultValue("42")
    int maxThreads();
}

Properties props = new Properties(); // Load properties from a known source


ServerConfig cfg = ConfigFactory
    .create(ServerConfig.class, props);


System.out.println(cfg.hostname()); // And simply use them

This is a really nice way to deal with property files:-)