Bug 4662: Introduce a SemanticVersion concept - import processing
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / AbstractEffectiveModule.java
index f73b455b4d1d98431e42564f8f3e77327f0cd103..2367db331ad5315107737b31ee1afe794e896f98 100644 (file)
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
@@ -74,6 +75,7 @@ abstract class AbstractEffectiveModule<D extends DeclaredStatement<String>> exte
     private final Set<UsesNode> uses;
     private final Set<TypeDefinition<?>> typeDefinitions;
     private final Set<DataSchemaNode> publicChildNodes;
+    private final SemVer semanticVersion;
 
     AbstractEffectiveModule(final StmtContext<String, D, ? extends EffectiveStatement<String, ?>> ctx) {
         super(ctx);
@@ -86,6 +88,9 @@ abstract class AbstractEffectiveModule<D extends DeclaredStatement<String>> exte
         YangVersionEffectiveStatementImpl yangVersionStmt = firstEffective(YangVersionEffectiveStatementImpl.class);
         this.yangVersion = (yangVersionStmt == null) ? "1" : yangVersionStmt.argument();
 
+        SemanticVersionEffectiveStatementImpl semanticVersionStmt = firstEffective(SemanticVersionEffectiveStatementImpl.class);
+        this.semanticVersion = (semanticVersionStmt == null) ? DEFAULT_SEMANTIC_VERSION : semanticVersionStmt.argument();
+
         OrganizationEffectiveStatementImpl organizationStmt = firstEffective(OrganizationEffectiveStatementImpl.class);
         this.organization = (organizationStmt == null) ? null : organizationStmt.argument();
 
@@ -215,7 +220,11 @@ abstract class AbstractEffectiveModule<D extends DeclaredStatement<String>> exte
 
         this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
         this.augmentations = ImmutableSet.copyOf(augmentationsInit);
-        this.imports = ImmutableSet.copyOf(resolveModuleImports(importsInit, ctx));
+        if (ctx.isEnabledSemanticVersioning()) {
+            this.imports = ImmutableSet.copyOf(importsInit);
+        } else {
+            this.imports = ImmutableSet.copyOf(resolveModuleImports(importsInit, ctx));
+        }
         this.notifications = ImmutableSet.copyOf(notificationsInit);
         this.rpcs = ImmutableSet.copyOf(rpcsInit);
         this.deviations = ImmutableSet.copyOf(deviationsInit);
@@ -381,6 +390,11 @@ abstract class AbstractEffectiveModule<D extends DeclaredStatement<String>> exte
         return uses;
     }
 
+    @Override
+    public SemVer getSemanticVersion() {
+        return semanticVersion;
+    }
+
     @Override
     public String toString() {
         return this.getClass().getSimpleName() + "[" +