Make sure refines are declaration-ordered 06/87806/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 17 Feb 2020 11:42:21 +0000 (12:42 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 17 Feb 2020 11:42:21 +0000 (12:42 +0100)
Our current way of constructing the map is not predictable, as we
it depends on JVM specifics. Make sure the map retains declaration
order.

Change-Id: Ie451e2e8bdbbdd5f5ae444502bc4b291876567b8
JIRA: YANGTOOLS-1084
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/UsesNode.java
yang/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/uses/UsesEffectiveStatementImpl.java
yang/yang-parser-rfc7950/src/test/java/org/opendaylight/yangtools/yang/stmt/GroupingAndUsesStmtTest.java

index f4c60e4e959b7ebbb6073ef810a71b038cf8fcf2..a795ff7010aa66a97415a7ed794ad6631f33517c 100644 (file)
@@ -35,7 +35,7 @@ public interface UsesNode extends WhenConditionAware, WithStatus, CopyableNode {
     /**
      * Some of the properties of each node in the grouping can be refined with the "refine" statement.
      *
-     * @return Map, where key is schema path of refined node and value is refined node
+     * @return Map, where key is schema node identifier of refined node and value is refined node.
      */
     @NonNull Map<Descendant, SchemaNode> getRefines();
 }
index fe7d1cd9b342da8e0a3c31e893ff24d5d53e3b0f..33073457b889376771b4b4f4c9d0e3dc3f4096c5 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.uses;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import java.util.Collection;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.Optional;
@@ -57,7 +57,7 @@ final class UsesEffectiveStatementImpl extends AbstractEffectiveDocumentedNode<Q
 
         // initSubstatementCollections
         final Set<AugmentationSchemaNode> augmentationsInit = new LinkedHashSet<>();
-        final Map<Descendant, SchemaNode> refinesInit = new HashMap<>();
+        final Map<Descendant, SchemaNode> refinesInit = new LinkedHashMap<>();
         for (final EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements()) {
             if (effectiveStatement instanceof AugmentationSchemaNode) {
                 final AugmentationSchemaNode augmentationSchema = (AugmentationSchemaNode) effectiveStatement;
index b419d94088886835aed60d822a02d27e9b7a5478..7dbdd17aa72bfb613587c6d1ab37dda363e19cd6 100644 (file)
@@ -116,8 +116,8 @@ public class GroupingAndUsesStmtTest {
         assertEquals(4, refines.size());
 
         assertEquals(ImmutableList.of(
-            Descendant.of(QName.create(peer, "port")),
             Descendant.of(QName.create(peer, "address")),
+            Descendant.of(QName.create(peer, "port")),
             Descendant.of(QName.create(peer, "addresses")),
             Descendant.of(QName.create(peer, "addresses"), QName.create(peer, "id"))),
             new ArrayList<>(refines.keySet()));