Section Interfaces

Config sections can also be accessed via interface proxies using {@link oaj.config.Config#getSectionAsInterface(String,Class)}.

While section maps and beans retrieve copies of the configuration data at the time of the method call, section interfaces can also be use to set values in the underlying configuration.

##### Example:

// Example config file [MySection] string = foo int = 123 enum = ONE bean = {foo:'bar',baz:123} int3dArray = [[[123,null],null],null] bean1d3dListMap = {key:[[[[{foo:'bar',baz:123}]]]]}

// Example interface. // Setters are optional. public interface MyConfigInterface { String getString(); void setString(String x); int getInt(); void setInt(int x); MyEnum getEnum(); void setEnum(MyEnum x); MyBean getBean(); void setBean(MyBean x); int[][][] getInt3dArray(); void setInt3dArray(int[][][] x); Map<String,List<MyBean[][][]>> getBean1d3dListMap(); void setBean1d3dListMap(Map<String,List<MyBean[][][]>> x); } // Example usage. Config c = Config.create("MyConfig.cfg").build(); MyConfigInterface ci = c.getSectionAsInterface("MySection", MyConfigInterface.class); // Read a value. int myInt = ci.getInt(); // Write a value. ci.setBean(new MyBean()); // Commit your changes to the store. c.commit();