YamlFile extends YamlConfiguration implements Commentable { @Override public void setComment(final String path, final String comment, final CommentType type) { if (this.commentMapper == null) { this.useComments = true; this.commentMapper = new CommentMapper(this.options()); } this.commentMapper.setComment(path, comment, type); } YamlFile();  YamlFile(final String path);  YamlFile(final File file);  YamlFile(final URI uri);  YamlFile(final URL url); void save(); String saveToString(); @Override void setComment(final String path, final String comment, final CommentType type); @Override String getComment(final String path, final CommentType type); void load(); void loadWithComments(); @Override void loadFromString(final String contents); void createOrLoad(); void createOrLoadWithComments(); boolean exists(); void createNewFile(final boolean overwrite); void deleteFile(); long getSize(); String getFilePath(); File getConfigurationFile(); void setConfigurationFile(final String path); void setConfigurationFile(final URI uri); void setConfigurationFile(final File file); File copyTo(final String path); void copyTo(final File file); String fileToString(); @Override String toString(); static YamlFile loadConfiguration(final File file, boolean withComments); static YamlFile loadConfiguration(final File file); static YamlFile loadConfiguration(final InputStream stream, boolean withComments); static YamlFile loadConfiguration(final InputStream stream); static YamlFile loadConfiguration(final Reader reader, boolean withComments); static YamlFile loadConfiguration(final Reader reader);  }
@Test void setComment() throws Exception { final YamlFile yamlFile = new YamlFile(YamlFileTest.getResourceURI("test-comments.yml")); yamlFile.loadWithComments(); yamlFile.setComment("test.string", "Edited hello comment!"); yamlFile.setComment("test.string", "Edited hello side comment!", CommentType.SIDE); MatcherAssert.assertThat( "Couldn't parse the comments correctly!", yamlFile.getComment("test.string"), new IsEqual<>("Edited hello comment!") ); MatcherAssert.assertThat( "Couldn't parse the comments correctly!", yamlFile.getComment("test.string", CommentType.SIDE), new IsEqual<>("Edited hello side comment!") ); }