public static Map<String, Object> extractMap(AppConfig config) { Map<String, Object> map = new LinkedHashMap<>(); config.getPropertyNames().forEach(key -> { String value = config.getProperty(key); extractMap(map, key, value); }); return map; }
public static Map<String, Object> extractMap(AppConfig config) { Map<String, Object> map = new LinkedHashMap<>(); config.getPropertyNames().forEach(key -> { String value = config.getProperty(key); extractMap(map, key, value); }); return map; }
public static Map<String, Object> extractMap(AppConfig config, Map<String, String> extraConfig, String prefix) { Map<String, String> props = new LinkedHashMap<>(); final String keyPrefix = prefix.endsWith(".") ? prefix : prefix + "."; config.getPropertyNames().forEach(key -> { if(key.startsWith(keyPrefix)) { props.put(key.substring(keyPrefix.length()), config.getProperty(key)); } }); if(null != extraConfig) { extraConfig.forEach((key, value) -> { if (key.startsWith(keyPrefix)) { props.put(key.substring(keyPrefix.length()), value); } }); } Map<String, Object> map = new LinkedHashMap<>(); props.forEach((k, v) -> { extractMap(map, k, v); }); return map; }
public static Map<String, Object> extractMap(AppConfig config, Map<String, String> extraConfig, String prefix) { Map<String, String> props = new LinkedHashMap<>(); final String keyPrefix = prefix.endsWith(".") ? prefix : prefix + "."; config.getPropertyNames().forEach(key -> { if(key.startsWith(keyPrefix)) { props.put(key.substring(keyPrefix.length()), config.getProperty(key)); } }); if(null != extraConfig) { extraConfig.forEach((key, value) -> { if (key.startsWith(keyPrefix)) { props.put(key.substring(keyPrefix.length()), value); } }); } Map<String, Object> map = new LinkedHashMap<>(); props.forEach((k, v) -> { extractMap(map, k, v); }); return map; }