ConfigReader implements Closeable { public Config read() { Verify.isFalse(closed, () -> new IllegalStateException("ConfigReader has been closed.")); Config config = new Config(); previousNode = config; parent = config; while (scanner.hasNextLine()) { String line = readNewLine(); String trimmed = line.trim(); handleLine(line, trimmed); } return config; } ConfigReader(Path filePath);  ConfigReader(InputStream in);  ConfigReader(BufferedReader bufferedReader);  ConfigReader(Scanner scanner); Config read(); @Override void close();  }
@Test void valueAfterAList() { String read = "Test:\n" + " List:\n" + " - First\n" + " - Second\n" + " - Third\n" + " Value: Example"; try (ConfigReader reader = new ConfigReader(new Scanner(read))) { Config readConfig = reader.read(); assertTrue(readConfig.getNode("Test.List").isPresent()); assertTrue(readConfig.getNode("Test.Value").isPresent()); assertFalse(readConfig.getNode("Test.List.Value").isPresent()); assertEquals("Example", readConfig.getString("Test.Value")); assertEquals(Arrays.asList("First", "Second", "Third"), readConfig.getStringList("Test.List")); } }
@Test void valueAfterAList2() { String read = "Plugins:\n" + " Factions:\n" + " HideFactions:\n" + " - ExampleFaction\n" + " Towny:\n" + " HideTowns:\n" + " - ExampleTown\n" + " Enabled: true"; try (ConfigReader reader = new ConfigReader(new Scanner(read))) { Config readConfig = reader.read(); assertTrue(readConfig.getNode("Plugins.Towny.HideTowns").isPresent()); assertTrue(readConfig.getNode("Plugins.Towny.Enabled").isPresent()); assertFalse(readConfig.getNode("Plugins.Towny.HideTowns.Enabled").isPresent()); } }