/** * Overrides the default getProperty implementation to create nested ConfigObject instances on demand * for non-existent keys */ public Object getProperty(String name) { if ("configFile".equals(name)) return this.configFile; if (!containsKey(name)) { ConfigObject prop = new ConfigObject(this.configFile); put(name, prop); return prop; } return get(name); }
/** * Overrides the default getProperty implementation to create nested ConfigObject instances on demand * for non-existent keys */ public Object getProperty(String name) { if ("configFile".equals(name)) return this.configFile; if (!containsKey(name)) { ConfigObject prop = new ConfigObject(this.configFile); put(name, prop); return prop; } return get(name); }
private static void createFlatConfig(ConfigObject currentConfigObject, Map<String, Object> rootConfig, String prefix) { Set keySet = currentConfigObject.keySet(); for (Object key : keySet) { Object value = currentConfigObject.get(key); if(value instanceof ConfigObject) { ConfigObject sub = ((ConfigObject) value).clone(); String fullPath = prefix + key; if(!sub.isEmpty()) { Map flattened = sub.flatten(); sub.putAll(flattened); createFlatConfig(sub, rootConfig, fullPath + "."); if(!rootConfig.containsKey(fullPath)) { rootConfig.put(fullPath, sub); } } } else { rootConfig.put(prefix + key, value); } } }