mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-04 10:38:19 +08:00
chore(yaml): Simply the yaml dumper
This commit is contained in:
@@ -104,17 +104,10 @@ public class YAMLSource extends FileConfigSource<MemorySection, Map<?, ?>, YAMLS
|
|||||||
public String saveToString(ConfigureSection section) {
|
public String saveToString(ConfigureSection section) {
|
||||||
MappingNode mappingNode = this.toNodeTree(section);
|
MappingNode mappingNode = this.toNodeTree(section);
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
if ((mappingNode.getBlockComments() == null || mappingNode.getBlockComments().isEmpty())
|
if (mappingNode.getValue().isEmpty()) {
|
||||||
&& (mappingNode.getEndComments() == null || mappingNode.getEndComments().isEmpty())
|
mappingNode.setFlowStyle(DumperOptions.FlowStyle.FLOW);
|
||||||
&& (mappingNode.getInLineComments() == null || mappingNode.getInLineComments().isEmpty())
|
|
||||||
&& mappingNode.getValue().isEmpty()) {
|
|
||||||
writer.write("");
|
|
||||||
} else {
|
|
||||||
if (mappingNode.getValue().isEmpty()) {
|
|
||||||
mappingNode.setFlowStyle(DumperOptions.FlowStyle.FLOW);
|
|
||||||
}
|
|
||||||
this.yaml.serialize(mappingNode, writer);
|
|
||||||
}
|
}
|
||||||
|
this.yaml.serialize(mappingNode, writer);
|
||||||
return writer.toString();
|
return writer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +143,7 @@ public class YAMLSource extends FileConfigSource<MemorySection, Map<?, ?>, YAMLS
|
|||||||
}
|
}
|
||||||
if (mappingNode == null) return MemorySection.root(this);
|
if (mappingNode == null) return MemorySection.root(this);
|
||||||
|
|
||||||
|
|
||||||
Map<String, Object> map = new LinkedHashMap<>();
|
Map<String, Object> map = new LinkedHashMap<>();
|
||||||
this.constructMap(mappingNode, map);
|
this.constructMap(mappingNode, map);
|
||||||
return MemorySection.root(this, map);
|
return MemorySection.root(this, map);
|
||||||
|
|||||||
Reference in New Issue
Block a user