Remove getSemanticVersion() 67/100967/4
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 4 May 2022 09:51:16 +0000 (11:51 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 4 May 2022 11:40:29 +0000 (13:40 +0200)
OpenConfig versions are not used anywhere and have been deprecated.
Remove them.

JIRA: YANGTOOLS-1432
Change-Id: Ibb4a000dca927fa660de68fc18754057c33a4106
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ModuleImport.java
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ModuleLike.java
model/yang-model-ri/src/main/java/org/opendaylight/yangtools/yang/model/ri/stmt/impl/eff/ImportEffectiveStatementImpl.java
model/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextProxyTest.java
parser/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/DependencyResolver.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/repo/YangModelDependencyInfo.java
parser/yang-parser-rfc7950/src/main/java/org/opendaylight/yangtools/yang/parser/rfc7950/stmt/AbstractEffectiveModule.java

index 3e353cd0794dfe8c451735f2c86f46f794a023ce..30ff0197c1abda456e76c5e12e354f9a7fe1efa6 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.model.api;
 
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
 
@@ -39,15 +38,6 @@ public interface ModuleImport extends DocumentedNode, EffectiveStatementEquivale
      */
     Optional<Revision> getRevision();
 
-    /**
-     * Returns the semantic version to import.
-     *
-     * @return Semantic version of module to import
-     * @deprecated Semantic version imports are deprecated.
-     */
-    @Deprecated(since = "8.0.4", forRemoval = true)
-    Optional<SemVer> getSemanticVersion();
-
     /**
      * Returns the prefix associated with the imported module.
      *
index b275b1a845f86a019c38c8d57cbee7f53ac5cb06..dea9d3e3ef6c1c85c83269cbe4d5fc8a5d7f215e 100644 (file)
@@ -12,7 +12,6 @@ import java.util.Collection;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.YangVersion;
 
 /**
@@ -28,17 +27,6 @@ public interface ModuleLike extends DataNodeContainer, DocumentedNode, Immutable
      */
     String getName();
 
-    /**
-     * Returns the semantic version of YANG module. If the semantic version is not specified, default semantic version
-     * of module is returned.
-     *
-     * @return SemVer semantic version of YANG module which is specified as argument of
-     *         {@code (urn:opendaylight:yang:extension:semantic-version?revision=2016-02-02)semantic-version} statement
-     * @deprecated Semantic version imports are deprecated.
-     */
-    @Deprecated(since = "8.0.4", forRemoval = true)
-    Optional<SemVer> getSemanticVersion();
-
     /**
      * Returns the prefix of the module.
      *
index 0a0818b75fffc2e928704e5ff4d531b993ab331c..2909933439fb41b0f172d2b24ad4ca530b9c743c 100644 (file)
@@ -11,13 +11,11 @@ import com.google.common.collect.ImmutableList;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
-import org.opendaylight.yangtools.yang.model.repo.api.SemVerSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.spi.meta.AbstractDeclaredEffectiveStatement.DefaultArgument.WithSubstatements;
 import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.DocumentedNodeMixin;
@@ -25,16 +23,12 @@ import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.D
 public final class ImportEffectiveStatementImpl extends WithSubstatements<String, ImportStatement>
         implements ImportEffectiveStatement, ModuleImport, DocumentedNodeMixin<String, ImportStatement> {
     private final @Nullable Revision revision;
-    private final @Nullable SemVer semVer;
 
     public ImportEffectiveStatementImpl(final ImportStatement declared,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements,
             final @NonNull SourceIdentifier importedSource) {
         super(declared, substatements);
         revision = importedSource.getRevision().orElse(null);
-        semVer = importedSource instanceof SemVerSourceIdentifier
-            ? ((SemVerSourceIdentifier) importedSource).getSemanticVersion().orElse(null)
-                : null;
     }
 
     @Override
@@ -42,12 +36,6 @@ public final class ImportEffectiveStatementImpl extends WithSubstatements<String
         return Optional.ofNullable(revision);
     }
 
-    @Override
-    @Deprecated(since = "8.0.4", forRemoval = true)
-    public Optional<SemVer> getSemanticVersion() {
-        return Optional.ofNullable(semVer);
-    }
-
     @Override
     public String getPrefix() {
         return getDeclared().getPrefix().argument();
index 0acdbfe81c06750e980abd3095c4a0a51d0905eb..1a3068a67e244aefcaff47d1006fb32049030d5f 100644 (file)
@@ -22,7 +22,6 @@ import java.util.List;
 import java.util.Optional;
 import java.util.Set;
 import org.junit.Test;
-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.Revision;
@@ -411,8 +410,7 @@ public class SchemaContextProxyTest {
         final ContainerSchemaNode mockedContainer = mock(ContainerSchemaNode.class);
         doReturn(Set.of(mockedContainer)).when(moduleConfig).getChildNodes();
 
-        final Collection<? extends DataSchemaNode> dataDefinitions =
-                filteringSchemaContextProxy.getDataDefinitions();
+        final Collection<? extends DataSchemaNode> dataDefinitions = filteringSchemaContextProxy.getDataDefinitions();
         assertTrue(dataDefinitions.contains(mockedContainer));
     }
 
@@ -598,12 +596,6 @@ public class SchemaContextProxyTest {
                     return module.getName();
                 }
 
-                @Override
-                @Deprecated(since = "8.0.4", forRemoval = true)
-                public Optional<SemVer> getSemanticVersion() {
-                    return module.getSemanticVersion();
-                }
-
                 @Override
                 public Optional<String> getDescription() {
                     return module.getDescription();
index 5598129ede65c96a055b1d738f2cd9dcc3a7eac0..e87c7d3cfbd5406972e40af9c20b9570a2e0721a 100644 (file)
@@ -20,7 +20,6 @@ import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Optional;
 import java.util.Set;
-import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportEffectiveStatement;
@@ -185,11 +184,6 @@ abstract class DependencyResolver {
             throw new UnsupportedOperationException();
         }
 
-        @Override
-        public Optional<SemVer> getSemanticVersion() {
-            return Optional.empty();
-        }
-
         @Override
         public String toString() {
             return MoreObjects.toStringHelper(this).add("parent", parent).toString();
index ff6173d166f781ac8c7a9daa99f180dbe4fa3a1f..73ca392e2041489583c27b5193305b107597dc0a 100644 (file)
@@ -10,8 +10,6 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.repo;
 import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.annotations.Beta;
-import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableSet;
 import java.io.IOException;
 import java.util.HashSet;
@@ -20,9 +18,6 @@ import java.util.Optional;
 import java.util.Set;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.concepts.SemVer;
-import org.opendaylight.yangtools.openconfig.model.api.OpenConfigStatements;
-import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
@@ -61,33 +56,20 @@ public abstract class YangModelDependencyInfo {
     private static final String REVISION_DATE = YangStmtMapping.REVISION_DATE.getStatementName().getLocalName();
     private static final String SUBMODULE = YangStmtMapping.SUBMODULE.getStatementName().getLocalName();
 
-    private static final String OPENCONFIG_VERSION = OpenConfigStatements.OPENCONFIG_VERSION.getStatementName()
-            .getLocalName();
-
     private final String name;
     private final Revision revision;
-    private final SemVer semVer;
     private final ImmutableSet<ModuleImport> submoduleIncludes;
     private final ImmutableSet<ModuleImport> moduleImports;
     private final ImmutableSet<ModuleImport> dependencies;
 
-    YangModelDependencyInfo(final String name, final String formattedRevision,
-            final ImmutableSet<ModuleImport> imports,
+    YangModelDependencyInfo(final String name, final String formattedRevision, final ImmutableSet<ModuleImport> imports,
             final ImmutableSet<ModuleImport> includes) {
-        this(name, formattedRevision, imports, includes, Optional.empty());
-    }
-
-    YangModelDependencyInfo(final String name, final String formattedRevision,
-            final ImmutableSet<ModuleImport> imports,
-            final ImmutableSet<ModuleImport> includes,
-            final Optional<SemVer> semVer) {
         this.name = name;
         revision = Revision.ofNullable(formattedRevision).orElse(null);
         moduleImports = imports;
         submoduleIncludes = includes;
         dependencies = ImmutableSet.<ModuleImport>builder()
                 .addAll(moduleImports).addAll(submoduleIncludes).build();
-        this.semVer = semVer.orElse(null);
     }
 
     /**
@@ -127,41 +109,19 @@ public abstract class YangModelDependencyInfo {
         return Optional.ofNullable(revision);
     }
 
-    /**
-     * Returns semantic version of module.
-     *
-     * @return semantic version
-     * @deprecated Semantic versioning is deprecated
-     */
-    @Deprecated(since = "8.0.4", forRemoval = true)
-    public Optional<SemVer> getSemanticVersion() {
-        return Optional.ofNullable(semVer);
-    }
-
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = 1;
         result = prime * result + Objects.hashCode(name);
         result = prime * result + Objects.hashCode(revision);
-        result = prime * result + Objects.hashCode(semVer);
         return result;
     }
 
     @Override
     public boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (!(obj instanceof YangModelDependencyInfo)) {
-            return false;
-        }
-        final YangModelDependencyInfo other = (YangModelDependencyInfo) obj;
-        return Objects.equals(name, other.name) && Objects.equals(revision, other.revision)
-                && Objects.equals(semVer, other.semVer);
+        return this == obj || obj instanceof YangModelDependencyInfo other
+            && Objects.equals(name, other.name) && Objects.equals(revision, other.revision);
     }
 
     /**
@@ -217,11 +177,10 @@ public abstract class YangModelDependencyInfo {
             final SourceIdentifier source) {
         final String name = safeStringArgument(source, module, "module name");
         final String latestRevision = getLatestRevision(module, source);
-        final Optional<SemVer> semVer = Optional.ofNullable(findSemanticVersion(module, source));
         final ImmutableSet<ModuleImport> imports = parseImports(module, source);
         final ImmutableSet<ModuleImport> includes = parseIncludes(module, source);
 
-        return new ModuleDependencyInfo(name, latestRevision, imports, includes, semVer);
+        return new ModuleDependencyInfo(name, latestRevision, imports, includes);
     }
 
     private static ImmutableSet<ModuleImport> parseImports(final IRStatement module,
@@ -232,28 +191,12 @@ public abstract class YangModelDependencyInfo {
                 final String importedModuleName = safeStringArgument(source, substatement, "imported module name");
                 final String revisionDateStr = getRevisionDateString(substatement, source);
                 final Revision revisionDate = Revision.ofNullable(revisionDateStr).orElse(null);
-                final SemVer importSemVer = findSemanticVersion(substatement, source);
-                result.add(new ModuleImportImpl(importedModuleName, revisionDate, importSemVer));
+                result.add(new ModuleImportImpl(importedModuleName, revisionDate));
             }
         }
         return ImmutableSet.copyOf(result);
     }
 
-    @Beta
-    @Deprecated(since = "8.0.4", forRemoval = true)
-    public static SemVer findSemanticVersion(final IRStatement statement, final SourceIdentifier source) {
-        String semVerString = null;
-        for (final IRStatement substatement : statement.statements()) {
-            // FIXME: this should also check we are using a prefix
-            if (OPENCONFIG_VERSION.equals(substatement.keyword().identifier())) {
-                semVerString = safeStringArgument(source,  substatement, "version string");
-                break;
-            }
-        }
-
-        return Strings.isNullOrEmpty(semVerString) ? null : SemVer.valueOf(semVerString);
-    }
-
     private static boolean isBuiltin(final IRStatement stmt, final String localName) {
         final IRKeyword keyword = stmt.keyword();
         return keyword instanceof Unqualified && localName.equals(keyword.identifier());
@@ -336,14 +279,13 @@ public abstract class YangModelDependencyInfo {
      */
     public static final class ModuleDependencyInfo extends YangModelDependencyInfo {
         ModuleDependencyInfo(final String name, final String latestRevision, final ImmutableSet<ModuleImport> imports,
-                final ImmutableSet<ModuleImport> includes, final Optional<SemVer> semVer) {
-            super(name, latestRevision, imports, includes, semVer);
+                final ImmutableSet<ModuleImport> includes) {
+            super(name, latestRevision, imports, includes);
         }
 
         @Override
         public String toString() {
             return "Module [name=" + getName() + ", revision=" + getRevision()
-                + ", semanticVersion=" + getSemanticVersion().orElse(null)
                 + ", dependencies=" + getDependencies()
                 + "]";
         }
@@ -372,9 +314,9 @@ public abstract class YangModelDependencyInfo {
 
         @Override
         public String toString() {
-            return "Submodule [name=" + getName() + ", revision="
-                    + getRevision() + ", dependencies=" + getDependencies()
-                    + "]";
+            return "Submodule [name=" + getName() + ", revision=" + getRevision()
+                + ", dependencies=" + getDependencies()
+                + "]";
         }
     }
 
@@ -383,25 +325,17 @@ public abstract class YangModelDependencyInfo {
      */
     // FIXME: this is a rather nasty misuse of APIs :(
     private static final class ModuleImportImpl implements ModuleImport {
-
+        private final @NonNull String moduleName;
         private final Revision revision;
-        private final SemVer semVer;
-        private final String name;
 
         ModuleImportImpl(final @NonNull String moduleName, final @Nullable Revision revision) {
-            this(moduleName, revision, null);
-        }
-
-        ModuleImportImpl(final @NonNull String moduleName, final @Nullable Revision revision,
-                final @Nullable SemVer semVer) {
-            name = requireNonNull(moduleName, "Module name must not be null.");
+            this.moduleName = requireNonNull(moduleName, "Module name must not be null.");
             this.revision = revision;
-            this.semVer = semVer;
         }
 
         @Override
         public String getModuleName() {
-            return name;
+            return moduleName;
         }
 
         @Override
@@ -409,12 +343,6 @@ public abstract class YangModelDependencyInfo {
             return Optional.ofNullable(revision);
         }
 
-        @Override
-        @Deprecated(forRemoval = true)
-        public Optional<SemVer> getSemanticVersion() {
-            return Optional.ofNullable(semVer);
-        }
-
         @Override
         public String getPrefix() {
             throw new UnsupportedOperationException();
@@ -439,29 +367,20 @@ public abstract class YangModelDependencyInfo {
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result + Objects.hashCode(name);
+            result = prime * result + Objects.hashCode(moduleName);
             result = prime * result + Objects.hashCode(revision);
-            result = prime * result + Objects.hashCode(semVer);
             return result;
         }
 
         @Override
         public boolean equals(final Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (!(obj instanceof ModuleImportImpl)) {
-                return false;
-            }
-            final ModuleImportImpl other = (ModuleImportImpl) obj;
-            return name.equals(other.name) && Objects.equals(revision, other.revision)
-                    && Objects.equals(getSemanticVersion(), other.getSemanticVersion());
+            return this == obj || obj instanceof ModuleImportImpl other
+                && moduleName.equals(other.moduleName) && Objects.equals(revision, other.revision);
         }
 
         @Override
         public String toString() {
-            return "ModuleImportImpl [name=" + name + ", revision="
-                    + QName.formattedRevision(Optional.ofNullable(revision)) + ", semanticVersion=" + semVer + "]";
+            return "ModuleImportImpl [name=" + moduleName + ", revision=" + revision + "]";
         }
     }
 }
index fb7077ebde6c00d16466362b3c7463abfa422535..323587af5c780dca35a877317616e5eff5413cf5 100644 (file)
@@ -20,8 +20,6 @@ import java.util.LinkedHashSet;
 import java.util.Optional;
 import java.util.Set;
 import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.yangtools.concepts.SemVer;
-import org.opendaylight.yangtools.openconfig.model.api.OpenConfigVersionEffectiveStatement;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.UnresolvedQName.Unqualified;
 import org.opendaylight.yangtools.yang.common.YangVersion;
@@ -195,11 +193,6 @@ public abstract class AbstractEffectiveModule<D extends DeclaredStatement<Unqual
         return uses;
     }
 
-    @Override
-    public Optional<SemVer> getSemanticVersion() {
-        return findFirstEffectiveSubstatementArgument(OpenConfigVersionEffectiveStatement.class);
-    }
-
     protected static final @NonNull String findPrefix(final CommonStmtCtx stmt,
             final Collection<? extends EffectiveStatement<?, ?>> substatements, final String type, final String name) {
         return substatements.stream()