Rework NormalizedNode type hierarchy
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / InstanceIdToSimpleNodes.java
index 8c183c635e710bba794246c4d46acdeac6f67029..0d66db347b1b91a6a576fb65055a27a0f265b2e7 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgum
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 
@@ -31,13 +31,13 @@ abstract class InstanceIdToSimpleNodes<T extends PathArgument> extends InstanceI
     }
 
     @Override
-    final NormalizedNode<?, ?> create(final PathArgument first, final Iterator<PathArgument> others,
-            final Optional<NormalizedNode<?, ?>> deepestChild) {
-        final NormalizedNodeAttrBuilder<? extends PathArgument, Object,
-                ? extends NormalizedNode<? extends PathArgument, Object>> builder = getBuilder(first);
+    final NormalizedNode create(final PathArgument first, final Iterator<PathArgument> others,
+            final Optional<NormalizedNode> deepestChild) {
+        final NormalizedNodeBuilder<? extends PathArgument, Object, ? extends NormalizedNode> builder =
+            getBuilder(first);
 
         if (deepestChild.isPresent()) {
-            builder.withValue(deepestChild.get().getValue());
+            builder.withValue(deepestChild.orElseThrow().body());
         }
 
         return builder.build();
@@ -53,8 +53,8 @@ abstract class InstanceIdToSimpleNodes<T extends PathArgument> extends InstanceI
         return false;
     }
 
-    abstract NormalizedNodeAttrBuilder<? extends PathArgument, Object,
-            ? extends NormalizedNode<? extends PathArgument, Object>> getBuilder(PathArgument node);
+    abstract NormalizedNodeBuilder<? extends PathArgument, Object, ? extends NormalizedNode> getBuilder(
+        PathArgument node);
 
     static final class LeafNormalization extends InstanceIdToSimpleNodes<NodeIdentifier> {
         LeafNormalization(final LeafSchemaNode potential) {
@@ -62,7 +62,7 @@ abstract class InstanceIdToSimpleNodes<T extends PathArgument> extends InstanceI
         }
 
         @Override
-        NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> getBuilder(final PathArgument node) {
+        NormalizedNodeBuilder<NodeIdentifier, Object, LeafNode<Object>> getBuilder(final PathArgument node) {
             return Builders.leafBuilder().withNodeIdentifier(getIdentifier());
         }
     }
@@ -73,7 +73,7 @@ abstract class InstanceIdToSimpleNodes<T extends PathArgument> extends InstanceI
         }
 
         @Override
-        NormalizedNodeAttrBuilder<NodeWithValue, Object, LeafSetEntryNode<Object>> getBuilder(final PathArgument node) {
+        NormalizedNodeBuilder<NodeWithValue, Object, LeafSetEntryNode<Object>> getBuilder(final PathArgument node) {
             checkArgument(node instanceof NodeWithValue);
             return Builders.leafSetEntryBuilder().withNodeIdentifier((NodeWithValue<?>) node)
                     .withValue(((NodeWithValue<?>) node).getValue());