- }
-
- private Class getDataContainerType(
- NormalizedNodeContainer<?, ?, ?> dataContainerNode) {
- if (dataContainerNode instanceof ChoiceNode) {
- return ChoiceNode.class;
- } else if (dataContainerNode instanceof AugmentationNode) {
- return AugmentationNode.class;
- } else if (dataContainerNode instanceof ContainerNode) {
- return ContainerNode.class;
- } else if (dataContainerNode instanceof MapEntryNode) {
- return MapEntryNode.class;
- } else if (dataContainerNode instanceof UnkeyedListEntryNode) {
- return UnkeyedListEntryNode.class;
- } else if (dataContainerNode instanceof MapNode) {
- return MapNode.class;
- } else if (dataContainerNode instanceof LeafSetNode){
- return LeafSetNode.class;
- }
- throw new IllegalArgumentException(
- "could not find the data container node type "
- + dataContainerNode.toString());
- }
-
- private void navigateNormalizedNodeContainerMixin(int level, final String parentPath,
- NormalizedNodeContainer<?, ?, ?> node, Node.Builder builderParent) {
- String newParentPath = parentPath + "/" + node.getIdentifier().toString();
-
- builderParent.setPath(node.getIdentifier().toString()).setType(
- this.getDataContainerType(node).getSimpleName());
- final Iterable<? extends NormalizedNode<?, ?>> value = node.getValue();
- for (NormalizedNode normalizedNode : value) {
- // child node builder
- Node.Builder builderChild = Node.newBuilder();
- if (normalizedNode instanceof MixinNode
- && normalizedNode instanceof NormalizedNodeContainer) {
- navigateNormalizedNodeContainerMixin(level + 1,newParentPath,
- (NormalizedNodeContainer) normalizedNode, builderChild);
- } else {
- navigateNormalizedNode(level,newParentPath, normalizedNode, builderChild);
- }
- builderParent.addChild(builderChild);