YamlConfiguration extends FileConfiguration { protected void convertMapsToSections(final Map<?, ?> input, final ConfigurationSection section) { for (final Map.Entry<?, ?> entry : input.entrySet()) { final String key = entry.getKey().toString(); final Object value = entry.getValue(); if (value instanceof Map) { this.convertMapsToSections((Map<?, ?>) value, section.createSection(key)); } else { section.set(key, value); } } }  static YamlConfiguration loadConfiguration(final File file); static YamlConfiguration loadConfiguration(final InputStream stream); static YamlConfiguration loadConfiguration(final Reader reader); @Override String saveToString(); @Override void loadFromString(final String contents); @Override YamlConfigurationOptions options();  }
@Test void convertMapsToSections() { final InputStreamOf stream = new InputStreamOf( new ResourceOf("test.yml")); final YamlConfiguration configuration = YamlConfiguration.loadConfiguration(stream); final Map<String, Object> map = new HashMap<>(); map.put("test", "hello"); map.put("test-2", false); map.put("test-3", 123); final MemoryConfiguration section = new MemoryConfiguration(); configuration.convertMapsToSections(map, section); MatcherAssert.assertThat( "Couldn't load section from the map!", section.getString("test"), new IsEqual<>("hello") ); MatcherAssert.assertThat( "Couldn't load section from the map!", section.getBoolean("test-2"), new IsEqual<>(false) ); MatcherAssert.assertThat( "Couldn't load section from the map!", section.getInt("test-3"), new IsEqual<>(123) ); }