Merge "bug 1128:POM Restructuring for Automated Release"
authorRobert Varga <rovarga@cisco.com>
Fri, 6 Jun 2014 15:03:05 +0000 (15:03 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 6 Jun 2014 15:03:05 +0000 (15:03 +0000)
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.xtend
code-generator/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/yangtools/yang/unified/doc/generator/GeneratorImpl.xtend
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java

index d2341b73309964759b57476237ea1e1a0ab159d9..620efbcee3da17b7fb6146f5bf4f5dedc763f388 100644 (file)
@@ -1156,7 +1156,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                     val List<QName> nodeNames = nodeSp.path
                     val List<QName> nodeNewNames = new ArrayList(nodeNames)
                     nodeNewNames.remove(nodeNewNames.size - 1)
-                    val SchemaPath nodeNewSp = new SchemaPath(nodeNewNames, nodeSp.absolute)
+                    val SchemaPath nodeNewSp = SchemaPath.create(nodeNewNames, nodeSp.absolute)
                     parentNode = findDataSchemaNode(schemaContext, nodeNewSp)
 
                     var SchemaNode parent
@@ -1179,7 +1179,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                         val List<QName> names = sp.path
                         val List<QName> newNames = new ArrayList(names)
                         newNames.remove(newNames.size - 1)
-                        val SchemaPath newSp = new SchemaPath(newNames, sp.absolute)
+                        val SchemaPath newSp = SchemaPath.create(newNames, sp.absolute)
                         parent = findDataSchemaNode(schemaContext, newSp)
                     }
                     var GeneratedTypeBuilder childOfType = findChildNodeByPath(parent.path)
@@ -1233,7 +1233,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 val List<QName> nodeNames = nodeSp.path
                 val List<QName> nodeNewNames = new ArrayList(nodeNames)
                 nodeNewNames.remove(nodeNewNames.size - 1)
-                val SchemaPath nodeNewSp = new SchemaPath(nodeNewNames, nodeSp.absolute)
+                val SchemaPath nodeNewSp = SchemaPath.create(nodeNewNames, nodeSp.absolute)
                 parent = findDataSchemaNode(schemaContext, nodeNewSp)
 
                 var GeneratedTypeBuilder childOfType = null;
index ba489413bddc602ff2950f0167799e5d36c64042..18fb86126e220765a0812737c6334c38ef2b0a07 100644 (file)
@@ -1252,7 +1252,7 @@ class GeneratorImpl {
             var i = 0;
             for (pathElement : path) {
                 actual.add(pathElement)
-                val DataSchemaNode nodeByPath = childNodes.get(new SchemaPath(actual, absolute))
+                val DataSchemaNode nodeByPath = childNodes.get(SchemaPath.create(actual, absolute))
                 if (!(nodeByPath instanceof ChoiceNode) && !(nodeByPath instanceof ChoiceCaseNode)) {
                     result.append(pathElement.localName)
                     if (i != path.size - 1) {
index b5ae91f7e9563a5196b43f28b169c11b9f3c2878..1ff28fbeeafe67d7503a6114db503dde245094e1 100644 (file)
@@ -193,7 +193,7 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
         for (final PathArgument a : getPathArguments()) {
             if (type.equals(a.getType())) {
                 @SuppressWarnings("unchecked")
-                final InstanceIdentifier<I> ret = (InstanceIdentifier<I>) create(Iterables.limit(getPathArguments(), i));
+                final InstanceIdentifier<I> ret = (InstanceIdentifier<I>) internalCreate(Iterables.limit(getPathArguments(), i));
                 return ret;
             }
 
@@ -385,20 +385,17 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
     }
 
     /**
-     * Create an instance identifier for a very specific object type.
+     * Create an instance identifier for a very specific object type. This method
+     * implements {@link #create(Iterable)} semantics, except it is used by internal
+     * callers, which have assured that the argument is an immutable Iterable.
      *
-     * Example
-     * <pre>
-     *  List<PathArgument> path = Arrays.asList(new Item(Nodes.class))
-     *  new InstanceIdentifier(path);
-     * </pre>
      *
      * @param pathArguments The path to a specific node in the data tree
      * @return InstanceIdentifier instance
      * @throws IllegalArgumentException if pathArguments is empty or
      *         contains a null element.
      */
-    public static InstanceIdentifier<?> create(final Iterable<? extends PathArgument> pathArguments) {
+    private static InstanceIdentifier<?> internalCreate(final Iterable<PathArgument> pathArguments) {
         final Iterator<? extends PathArgument> it = Preconditions.checkNotNull(pathArguments, "pathArguments may not be null").iterator();
         final HashCodeBuilder<PathArgument> hashBuilder = new HashCodeBuilder<>();
         boolean wildcard = false;
@@ -417,14 +414,31 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
         }
         Preconditions.checkArgument(a != null, "pathArguments may not be empty");
 
-        final Iterable<PathArgument> immutableArguments;
+        return trustedCreate(a, pathArguments, hashBuilder.toInstance(), wildcard);
+    }
+
+    /**
+     * Create an instance identifier for a very specific object type.
+     *
+     * Example
+     * <pre>
+     *  List<PathArgument> path = Arrays.asList(new Item(Nodes.class))
+     *  new InstanceIdentifier(path);
+     * </pre>
+     *
+     * @param pathArguments The path to a specific node in the data tree
+     * @return InstanceIdentifier instance
+     * @throws IllegalArgumentException if pathArguments is empty or
+     *         contains a null element.
+     */
+    public static InstanceIdentifier<?> create(final Iterable<? extends PathArgument> pathArguments) {
         if (pathArguments instanceof ImmutableCollection<?>) {
-            immutableArguments = (Iterable<PathArgument>) pathArguments;
+            @SuppressWarnings("unchecked")
+            final Iterable<PathArgument> immutableArguments = (Iterable<PathArgument>) pathArguments;
+            return internalCreate(immutableArguments);
         } else {
-            immutableArguments = ImmutableList.copyOf(pathArguments);
+            return internalCreate(ImmutableList.copyOf(pathArguments));
         }
-
-        return trustedCreate(a, immutableArguments, hashBuilder.toInstance(), wildcard);
     }
 
     /**
@@ -496,10 +510,7 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
 
         @Override
         public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((type == null) ? 0 : type.hashCode());
-            return result;
+            return type.hashCode();
         }
 
         @Override
@@ -514,14 +525,7 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
                 return false;
             }
             final AbstractPathArgument<?> other = (AbstractPathArgument<?>) obj;
-            if (type == null) {
-                if (other.type != null) {
-                    return false;
-                }
-            } else if (!type.equals(other.type)) {
-                return false;
-            }
-            return true;
+            return type.equals(other.type);
         }
     }
 
@@ -563,12 +567,12 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
 
         @Override
         public boolean equals(final Object obj) {
-            return super.equals(obj) && obj.hashCode() == hashCode() && key.equals(((IdentifiableItem<?, ?>) obj).getKey());
+            return super.equals(obj) && key.equals(((IdentifiableItem<?, ?>) obj).getKey());
         }
 
         @Override
         public int hashCode() {
-            return key.hashCode();
+            return super.hashCode() * 31 + key.hashCode();
         }
 
         @Override