Add YangInstanceIdentifierBuilder.node(PathArgument) 07/21807/1
authorRobert Varga <rovarga@cisco.com>
Wed, 3 Jun 2015 17:17:20 +0000 (19:17 +0200)
committerRobert Varga <rovarga@cisco.com>
Wed, 3 Jun 2015 17:19:13 +0000 (19:19 +0200)
Forcing users of builder to not reuse PathArgument instances seems
wrong. Allow passing of pre-made PathArguments to a builder.

Change-Id: Iae7d2a8c8dd60542a11c946dc3ced18e09afb62b
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/YangInstanceIdentifier.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/YangInstanceIdentifierBuilder.java

index afbf3c1fe3688d498176524ce415bbcc87c81e3e..46489d31f34847292b238ab8e21f270f7574f025 100644 (file)
@@ -411,6 +411,14 @@ public abstract class YangInstanceIdentifier extends IterablePathArguments imple
      * Fluent Builder of Instance Identifier instances
      */
     public interface InstanceIdentifierBuilder extends Builder<YangInstanceIdentifier> {
+        /**
+         * Adds a {@link PathArgument} to to path arguments of resulting instance identifier.
+         *
+         * @param arg A {@link PathArgument} to be added
+         * @return this builder
+         */
+        InstanceIdentifierBuilder node(PathArgument arg);
+
         /**
          * Adds {@link NodeIdentifier} with supplied QName to path arguments of resulting instance identifier.
          *
index 4b872045772ff9ef3b82f09df7cd5373c0252007..63aec35904c598a933e56e8a193063db7480dfcc 100644 (file)
@@ -6,6 +6,7 @@
  */
 package org.opendaylight.yangtools.yang.data.api;
 
+import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import java.util.ArrayList;
 import java.util.List;
@@ -37,6 +38,11 @@ final class YangInstanceIdentifierBuilder implements InstanceIdentifierBuilder {
         return this;
     }
 
+    @Override
+    public InstanceIdentifierBuilder node(final PathArgument arg) {
+        return addArgument(Preconditions.checkNotNull(arg));
+    }
+
     @Override
     public InstanceIdentifierBuilder node(final QName nodeType) {
         return addArgument(new NodeIdentifier(nodeType));