Rework NormalizedNode type hierarchy
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / builder / impl / ImmutableLeafSetEntryNodeSchemaAwareBuilder.java
index 577ec37c6bbb5d89332d51157123cfba9903a61b..1621b892a42b3b88ae64991207d5dc8005b14697 100644 (file)
@@ -7,35 +7,36 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
 
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import static java.util.Objects.requireNonNull;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-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 com.google.common.base.Preconditions;
-
 public final class ImmutableLeafSetEntryNodeSchemaAwareBuilder<T> extends ImmutableLeafSetEntryNodeBuilder<T> {
-
     private final LeafListSchemaNode schema;
 
-    private ImmutableLeafSetEntryNodeSchemaAwareBuilder(LeafListSchemaNode schema) {
-        this.schema = Preconditions.checkNotNull(schema);
+    private ImmutableLeafSetEntryNodeSchemaAwareBuilder(final LeafListSchemaNode schema) {
+        this.schema = requireNonNull(schema);
     }
 
-    public static <T> NormalizedNodeAttrBuilder<InstanceIdentifier.NodeWithValue, T, LeafSetEntryNode<T>> create(LeafListSchemaNode schema) {
+    public static <T> @NonNull NormalizedNodeBuilder<NodeWithValue, T, LeafSetEntryNode<T>> create(
+            final LeafListSchemaNode schema) {
         return new ImmutableLeafSetEntryNodeSchemaAwareBuilder<>(schema);
     }
 
     @Override
-    public NormalizedNodeAttrBuilder<InstanceIdentifier.NodeWithValue, T, LeafSetEntryNode<T>> withValue(T value) {
-        super.withNodeIdentifier(new InstanceIdentifier.NodeWithValue(schema.getQName(), value));
-        // TODO check value type
-        return super.withValue(value);
+    public ImmutableLeafSetEntryNodeBuilder<T> withValue(final T withValue) {
+        super.withNodeIdentifier(new NodeWithValue<>(schema.getQName(), withValue));
+        // TODO check value type using TypeProvider ?
+        super.withValue(withValue);
+        return this;
     }
 
     @Override
-    public NormalizedNodeAttrBuilder<InstanceIdentifier.NodeWithValue, T, LeafSetEntryNode<T>> withNodeIdentifier(InstanceIdentifier.NodeWithValue nodeIdentifier) {
+    public ImmutableLeafSetEntryNodeBuilder<T> withNodeIdentifier(final NodeWithValue withNodeIdentifier) {
         throw new UnsupportedOperationException("Node identifier created from schema");
     }
-
 }