Fix YamlConfiguration not dumping comments
Not sure when it broke, but now it's fixed.
This commit is contained in:
parent
404a94c307
commit
e7da328dc6
|
@ -1,5 +1,6 @@
|
|||
package com.songoda.core.configuration.yaml;
|
||||
|
||||
import org.yaml.snakeyaml.DumperOptions;
|
||||
import org.yaml.snakeyaml.comments.CommentLine;
|
||||
import org.yaml.snakeyaml.comments.CommentType;
|
||||
import org.yaml.snakeyaml.events.CommentEvent;
|
||||
|
@ -16,7 +17,8 @@ import java.util.function.Supplier;
|
|||
public class YamlCommentRepresenter extends Representer {
|
||||
private final Map<String, Supplier<String>> nodeComments;
|
||||
|
||||
public YamlCommentRepresenter(Map<String, Supplier<String>> nodeComments) {
|
||||
public YamlCommentRepresenter(DumperOptions dumperOptions, Map<String, Supplier<String>> nodeComments) {
|
||||
super(dumperOptions);
|
||||
this.nodeComments = nodeComments;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ public class YamlConfiguration implements IConfiguration, HeaderCommentable, Nod
|
|||
this.nodeComments = Objects.requireNonNull(nodeComments);
|
||||
|
||||
this.yamlDumperOptions = createDefaultYamlDumperOptions();
|
||||
this.yamlCommentRepresenter = new YamlCommentRepresenter(this.nodeComments);
|
||||
this.yamlCommentRepresenter = new YamlCommentRepresenter(this.yamlDumperOptions, this.nodeComments);
|
||||
this.yaml = createDefaultYaml(this.yamlDumperOptions, this.yamlCommentRepresenter);
|
||||
}
|
||||
|
||||
|
@ -275,6 +275,8 @@ public class YamlConfiguration implements IConfiguration, HeaderCommentable, Nod
|
|||
|
||||
protected static DumperOptions createDefaultYamlDumperOptions() {
|
||||
DumperOptions dumperOptions = new DumperOptions();
|
||||
dumperOptions.setProcessComments(true);
|
||||
|
||||
dumperOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
dumperOptions.setIndentWithIndicator(true);
|
||||
dumperOptions.setIndicatorIndent(2);
|
||||
|
|
Loading…
Reference in New Issue