Deprecate schema-aware builders
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / builder / impl / ImmutableOrderedMapNodeSchemaAwareBuilder.java
index 7787f3f18f2536f3f3949b142f179d49cedafcef..aa1b7cafff8690e4ec43d02e5ebbfd33373e5f6c 100644 (file)
@@ -7,9 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import static java.util.Objects.requireNonNull;
+
+import java.util.Collections;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
@@ -17,26 +19,27 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNo
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 
+@Deprecated(since = "6.0.7", forRemoval = true)
 public class ImmutableOrderedMapNodeSchemaAwareBuilder extends ImmutableOrderedMapNodeBuilder {
-
     private final ListSchemaNode schema;
 
     protected ImmutableOrderedMapNodeSchemaAwareBuilder(final ListSchemaNode schema) {
-        this.schema = Preconditions.checkNotNull(schema);
-        super.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(schema.getQName()));
+        this.schema = requireNonNull(schema);
+        super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
     }
 
-    protected ImmutableOrderedMapNodeSchemaAwareBuilder(final ListSchemaNode schema, final ImmutableOrderedMapNode node) {
+    protected ImmutableOrderedMapNodeSchemaAwareBuilder(final ListSchemaNode schema,
+            final ImmutableOrderedMapNode node) {
         super(node);
-        this.schema = Preconditions.checkNotNull(schema);
-        super.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(schema.getQName()));
+        this.schema = requireNonNull(schema);
+        super.withNodeIdentifier(NodeIdentifier.create(schema.getQName()));
     }
 
-    public static CollectionNodeBuilder<MapEntryNode, OrderedMapNode> create(final ListSchemaNode schema) {
+    public static @NonNull CollectionNodeBuilder<MapEntryNode, OrderedMapNode> create(final ListSchemaNode schema) {
         return new ImmutableOrderedMapNodeSchemaAwareBuilder(schema);
     }
 
-    public static CollectionNodeBuilder<MapEntryNode, OrderedMapNode> create(final ListSchemaNode schema,
+    public static @NonNull CollectionNodeBuilder<MapEntryNode, OrderedMapNode> create(final ListSchemaNode schema,
         final MapNode node) {
         if (!(node instanceof ImmutableOrderedMapNode)) {
             throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
@@ -47,12 +50,14 @@ public class ImmutableOrderedMapNodeSchemaAwareBuilder extends ImmutableOrderedM
 
     @Override
     public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withChild(final MapEntryNode child) {
-        DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(), schema, Sets.newHashSet(schema.getQName()));
+        DataValidationException.checkLegalChild(schema.getQName().equals(child.getNodeType()), child.getIdentifier(),
+            schema, Collections.singleton(schema.getQName()));
         return super.withChild(child);
     }
 
     @Override
-    public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withNodeIdentifier(final YangInstanceIdentifier.NodeIdentifier nodeIdentifier) {
+    public CollectionNodeBuilder<MapEntryNode, OrderedMapNode> withNodeIdentifier(
+            final NodeIdentifier withNodeIdentifier) {
         throw new UnsupportedOperationException("Node identifier created from schema");
     }
 }