Use List for importedNamespace 30/102130/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Aug 2022 11:15:21 +0000 (13:15 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Aug 2022 11:34:50 +0000 (13:34 +0200)
Collection is too vague and we always implement it with a List, make
sure that is reflected in the declaration.

Change-Id: I1323e9649427ca31d9884f3a8d9c2fd221df933a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
parser/yang-parser-reactor/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java

index 676966472a3c7eb8099e3892686830269caed099..56a701efd964cd10413eab1757e4b7f6bd287b92 100644 (file)
@@ -111,7 +111,7 @@ final class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeha
      * - modules imported via 'import' statement
      * - parent module, declared via 'belongs-to' statement
      */
-    private Collection<RootStatementContext<?, ?, ?>> importedNamespaces = ImmutableList.of();
+    private List<RootStatementContext<?, ?, ?>> importedNamespaces = ImmutableList.of();
     private RootStatementContext<?, ?, ?> root;
     // TODO: consider using ExecutionOrder byte for these two
     private ModelProcessingPhase finishedPhase = ModelProcessingPhase.INIT;
@@ -219,11 +219,11 @@ final class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeha
 
     private void updateImportedNamespaces(final Class<?> type, final Object value) {
         if (BelongsToModuleContext.class.isAssignableFrom(type) || ImportedModuleContext.class.isAssignableFrom(type)) {
+            verify(value instanceof RootStatementContext, "Unexpected imported value %s", value);
+
             if (importedNamespaces.isEmpty()) {
                 importedNamespaces = new ArrayList<>(1);
             }
-
-            verify(value instanceof RootStatementContext);
             importedNamespaces.add((RootStatementContext<?, ?, ?>) value);
         }
     }