final MappingNode mappingNode = (MappingNode) yaml;
debug("writing map with size: {}", mappingNode.getValue().size());
for (NodeTuple tuple : mappingNode.getValue()) {
Node node = new Node();
if (tuple.getKeyNode() instanceof ScalarNode) {
ScalarNode scalarNode = (ScalarNode) tuple.getKeyNode();
String keyValue = scalarNode.getValue();
debug("keyValue: {}", keyValue);
node.setName(keyValue);
}
parent.addChild(node);
build(tuple.getValueNode(), node);
}
} else if (yaml instanceof SequenceNode) {
SequenceNode sequenceNode = (SequenceNode) yaml;
debug("writing sequence with size: {}", sequenceNode.getValue().size());
List<Object> list = Lists.newArrayList();
for (org.yaml.snakeyaml.nodes.Node node : sequenceNode.getValue()) {
if (node instanceof ScalarNode) {
list.add(getScalarValue((ScalarNode) node));
} else {
YamlProperties conf = new YamlProperties();
Node root = new Node();
conf.setRootNode(root);
build(node, root);
list.add(conf);
}
}
parent.setValue(list);
} else if (yaml instanceof ScalarNode) {
final ScalarNode scalarNode = (ScalarNode) yaml;
parent.setValue(getScalarValue(scalarNode));
}
}