Deprecate schema-aware builders
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / builder / impl / ImmutableAugmentationNodeSchemaAwareBuilder.java
index 33638de640eac8d4ab02b3b859e75a7788dcce6f..d20e8abd5effdd2dba12b2a697d5c67906da1f49 100644 (file)
@@ -7,55 +7,38 @@
  */
 package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
 
-import java.util.Set;
-
-import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataNodeContainerValidator;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
-import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-
-import com.google.common.collect.Sets;
+import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 
+@Deprecated(since = "6.0.7", forRemoval = true)
 public class ImmutableAugmentationNodeSchemaAwareBuilder extends ImmutableAugmentationNodeBuilder {
-
     private final DataNodeContainerValidator validator;
 
-    protected ImmutableAugmentationNodeSchemaAwareBuilder(AugmentationSchema schema) {
-        super();
+    protected ImmutableAugmentationNodeSchemaAwareBuilder(final AugmentationSchemaNode schema) {
         this.validator = new DataNodeContainerValidator(schema);
-        // TODO no QName for augmentation
-        super.withNodeIdentifier(new InstanceIdentifier.AugmentationIdentifier(null, getChildQNames(schema)));
-    }
-
-    // TODO move somewhere to UTIL
-    public static Set<QName> getChildQNames(AugmentationSchema schema) {
-        Set<QName> qnames = Sets.newHashSet();
-
-        for (DataSchemaNode dataSchemaNode : schema.getChildNodes()) {
-            qnames.add(dataSchemaNode.getQName());
-        }
-
-        return qnames;
+        super.withNodeIdentifier(DataSchemaContextNode.augmentationIdentifierFrom(schema));
     }
 
     @Override
-    public DataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> withNodeIdentifier(InstanceIdentifier.AugmentationIdentifier nodeIdentifier) {
+    public DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> withNodeIdentifier(
+            final AugmentationIdentifier withNodeIdentifier) {
         throw new UnsupportedOperationException("Node identifier created from schema");
     }
 
     @Override
-    public DataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> withChild(DataContainerChild<?, ?> child) {
-        validator.validateChild(child.getIdentifier());
-        return super.withChild(child);
+    public DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> withChild(
+            final DataContainerChild<?, ?> child) {
+        return super.withChild(validator.validateChild(child));
     }
 
-    public static DataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> create(AugmentationSchema schema) {
+    public static @NonNull DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> create(
+            final AugmentationSchemaNode schema) {
         return new ImmutableAugmentationNodeSchemaAwareBuilder(schema);
     }
-
-
 }