BUG-648: add missing copy builders 20/6820/2
authorRobert Varga <rovarga@cisco.com>
Thu, 8 May 2014 20:15:11 +0000 (22:15 +0200)
committerRobert Varga <rovarga@cisco.com>
Thu, 8 May 2014 22:17:48 +0000 (00:17 +0200)
This completes the set of initialized builders. We also complete picking
up nodeIdentifier from the passed-in node.

Change-Id: I229582457c77d9225c37f89054872abe0aeb016e
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/AbstractImmutableDataContainerNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAugmentationNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableChoiceNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableLeafSetNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableMapEntryNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableMapNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableOrderedLeafSetNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableOrderedMapNodeBuilder.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableUnkeyedListNodeBuilder.java

index 1479c8c3aeb05d213aaf7679b80b06cce1a13ea5..f06f56fba12715d072b4a77e70407910170e7f71 100644 (file)
@@ -39,6 +39,7 @@ abstract class AbstractImmutableDataContainerNodeBuilder<I extends InstanceIdent
     }
 
     protected AbstractImmutableDataContainerNodeBuilder(final AbstractImmutableDataContainerNode<I> node) {
+        this.nodeIdentifier = node.getIdentifier();
         this.value = node.getChildren();
         this.dirty = true;
     }
index 5784c7022ad519ec83e8a606ff93e143662b22ed..d8f6fa9dae5c1483f7c57b772fc7ec44dcd35da3 100644 (file)
@@ -18,15 +18,29 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
 
-import com.google.common.base.Preconditions;
-
 public class ImmutableAugmentationNodeBuilder
         extends AbstractImmutableDataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> {
 
+    protected ImmutableAugmentationNodeBuilder() {
+        super();
+    }
+
+    public ImmutableAugmentationNodeBuilder(ImmutableAugmentationNode node) {
+        super(node);
+    }
+
     public static DataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> create() {
         return new ImmutableAugmentationNodeBuilder();
     }
 
+    public static DataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> create(AugmentationNode node) {
+        if (!(node instanceof ImmutableAugmentationNode)) {
+            throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
+        }
+
+        return new ImmutableAugmentationNodeBuilder((ImmutableAugmentationNode)node);
+    }
+
     @Override
     public DataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> withChild(
             final DataContainerChild<?, ?> child) {
index 36719534d5c1f666e80c46a1b5b3e8b98973a7b6..82cebb4f4dc4a5e7d3241ec40d13e7cb16c638cd 100644 (file)
@@ -17,10 +17,26 @@ import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableD
 
 public class ImmutableChoiceNodeBuilder extends AbstractImmutableDataContainerNodeBuilder<InstanceIdentifier.NodeIdentifier, ChoiceNode> {
 
+    protected ImmutableChoiceNodeBuilder() {
+        super();
+    }
+
+    protected ImmutableChoiceNodeBuilder(final ImmutableChoiceNode node) {
+        super(node);
+    }
+
     public static DataContainerNodeBuilder<InstanceIdentifier.NodeIdentifier, ChoiceNode> create() {
         return new ImmutableChoiceNodeBuilder();
     }
 
+    public static DataContainerNodeBuilder<InstanceIdentifier.NodeIdentifier, ChoiceNode> create(final ChoiceNode node) {
+        if (!(node instanceof ImmutableChoiceNode)) {
+            throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
+        }
+
+        return new ImmutableChoiceNodeBuilder((ImmutableChoiceNode)node);
+    }
+
     @Override
     public ChoiceNode build() {
         return new ImmutableChoiceNode(getNodeIdentifier(), buildValue());
index 04863e7ec2e11779683702a23f6d95bd05d9d707..dfc6be4a18a65246d3c32b2a180536e4dd644b86 100644 (file)
@@ -38,8 +38,8 @@ public class ImmutableLeafSetNodeBuilder<T> implements ListNodeBuilder<T, LeafSe
     }
 
     protected ImmutableLeafSetNodeBuilder(final ImmutableLeafSetNode<T> node) {
-        value = node.getChildren();
         nodeIdentifier = node.getIdentifier();
+        value = node.getChildren();
         dirty = true;
     }
 
index 3ba4f20842d4a65c3d340bf16290f177d4aa6386..08d680eeec2aaec2154b566ddd22bcbfa9d10f0c 100644 (file)
@@ -20,8 +20,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.valid.DataValidationException;
 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerAttrNode;
 
-import com.google.common.base.Preconditions;
-
 public class ImmutableMapEntryNodeBuilder
         extends AbstractImmutableDataContainerNodeAttrBuilder<InstanceIdentifier.NodeIdentifierWithPredicates, MapEntryNode> {
 
index 17cdaffedaf6ffa370354a72b7d0283d361b57ec..c7c58e1899942c016bd4f4bc906ae886eaf08e07 100644 (file)
@@ -37,6 +37,7 @@ public class ImmutableMapNodeBuilder
     }
 
     protected ImmutableMapNodeBuilder(final ImmutableMapNode node) {
+        this.nodeIdentifier = node.getIdentifier();
         this.value = node.children;
         this.dirty = true;
     }
index e133fe6adcc8001622f2b6f8d3e523a7c0a4f2ab..d66f0228953bf4f171cc2ea41401f5f216d7ac9d 100644 (file)
@@ -39,8 +39,8 @@ public class ImmutableOrderedLeafSetNodeBuilder<T> implements ListNodeBuilder<T,
     }
 
     protected ImmutableOrderedLeafSetNodeBuilder(final ImmutableOrderedLeafSetNode<T> node) {
-        value = node.getChildren();
         nodeIdentifier = node.getIdentifier();
+        value = node.getChildren();
         dirty = true;
     }
 
index 167aa67f4488f05cc960662c6cd46f8daa426792..3f9e4d5f12ae029b6bd00199baa13c6e219af291 100644 (file)
@@ -37,6 +37,7 @@ public class ImmutableOrderedMapNodeBuilder
     }
 
     protected ImmutableOrderedMapNodeBuilder(final ImmutableOrderedMapNode node) {
+        this.nodeIdentifier = node.getIdentifier();
         this.value = node.children;
         this.dirty = true;
     }
index f4148da8c679143029d13ccafeb822650124bb6a..498b65824599fcf0c48ea91d6f9544a357402c70 100644 (file)
@@ -35,6 +35,7 @@ public class ImmutableUnkeyedListNodeBuilder implements CollectionNodeBuilder<Un
     }
 
     protected ImmutableUnkeyedListNodeBuilder(final ImmutableUnkeyedListNode node) {
+        this.nodeIdentifier = node.getIdentifier();
         this.value = new LinkedList<>();
         Iterables.addAll(value, node.getValue());
         this.dirty = true;