@Test void testFlattenNodes() { ConfigNode.ObjectNode node = ConfigNode.ObjectNode.builder() .addValue("simple", "value") .addList("list", ConfigNode.ListNode.builder() .addValue("first") .addValue("second") .build()) .addObject("object", ConfigNode.ObjectNode.builder() .addValue("value", "value2") .build()) .build(); Map<String, String> map = ConfigHelper.flattenNodes(node); Map<String, String> expected = Map.of( "simple", "value", "list.0", "first", "list.1", "second", "object.value", "value2" ); assertThat(map, is(expected)); }
public static Map<String, String> flattenNodes(ConfigNode.ObjectNode objectNode) { return ConfigHelper.flattenNodes(ConfigKeyImpl.of(), objectNode) .filter(e -> e.getValue() instanceof ValueNodeImpl) .collect(Collectors.toMap( e -> e.getKey().toString(), e -> Config.Key.escapeName(((ValueNodeImpl) e.getValue()).get()) )); }
ConfigHelper { public static Map<String, String> flattenNodes(ConfigNode.ObjectNode objectNode) { return ConfigHelper.flattenNodes(ConfigKeyImpl.of(), objectNode) .filter(e -> e.getValue() instanceof ValueNodeImpl) .collect(Collectors.toMap( e -> e.getKey().toString(), e -> Config.Key.escapeName(((ValueNodeImpl) e.getValue()).get()) )); } }
ConfigHelper { public static Map<String, String> flattenNodes(ConfigNode.ObjectNode objectNode) { return ConfigHelper.flattenNodes(ConfigKeyImpl.of(), objectNode) .filter(e -> e.getValue() instanceof ValueNodeImpl) .collect(Collectors.toMap( e -> e.getKey().toString(), e -> Config.Key.escapeName(((ValueNodeImpl) e.getValue()).get()) )); } private  ConfigHelper(); }
ConfigHelper { public static Map<String, String> flattenNodes(ConfigNode.ObjectNode objectNode) { return ConfigHelper.flattenNodes(ConfigKeyImpl.of(), objectNode) .filter(e -> e.getValue() instanceof ValueNodeImpl) .collect(Collectors.toMap( e -> e.getKey().toString(), e -> Config.Key.escapeName(((ValueNodeImpl) e.getValue()).get()) )); } private  ConfigHelper(); static Map<String, String> flattenNodes(ConfigNode.ObjectNode objectNode); }
ConfigHelper { public static Map<String, String> flattenNodes(ConfigNode.ObjectNode objectNode) { return ConfigHelper.flattenNodes(ConfigKeyImpl.of(), objectNode) .filter(e -> e.getValue() instanceof ValueNodeImpl) .collect(Collectors.toMap( e -> e.getKey().toString(), e -> Config.Key.escapeName(((ValueNodeImpl) e.getValue()).get()) )); } private  ConfigHelper(); static Map<String, String> flattenNodes(ConfigNode.ObjectNode objectNode);  }