Deprecate getSemanticVersion() for removal
[yangtools.git] / parser / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / repo / YangModelDependencyInfo.java
index 40b1116fd82e039b8eaa1f09a0dffd39b7325229..043ca62d4f80918af4d94877b5b1d29af7eae338 100644 (file)
@@ -11,7 +11,6 @@ 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.Splitter;
 import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableSet;
 import java.io.IOException;
@@ -64,8 +63,6 @@ public abstract class YangModelDependencyInfo {
 
     private static final String OPENCONFIG_VERSION = OpenConfigStatements.OPENCONFIG_VERSION.getStatementName()
             .getLocalName();
-    @Deprecated
-    private static final Splitter COLON_SPLITTER = Splitter.on(":").omitEmptyStrings().trimResults();
 
     private final String name;
     private final Revision revision;
@@ -85,10 +82,10 @@ public abstract class YangModelDependencyInfo {
             final ImmutableSet<ModuleImport> includes,
             final Optional<SemVer> semVer) {
         this.name = name;
-        this.revision = Revision.ofNullable(formattedRevision).orElse(null);
-        this.moduleImports = imports;
-        this.submoduleIncludes = includes;
-        this.dependencies = ImmutableSet.<ModuleImport>builder()
+        revision = Revision.ofNullable(formattedRevision).orElse(null);
+        moduleImports = imports;
+        submoduleIncludes = includes;
+        dependencies = ImmutableSet.<ModuleImport>builder()
                 .addAll(moduleImports).addAll(submoduleIncludes).build();
         this.semVer = semVer.orElse(null);
     }
@@ -134,7 +131,9 @@ public abstract class YangModelDependencyInfo {
      * 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);
     }
@@ -199,28 +198,6 @@ public abstract class YangModelDependencyInfo {
         throw new IllegalArgumentException("Root of parsed AST must be either module or submodule");
     }
 
-    /**
-     * Extracts {@link YangModelDependencyInfo} from input stream containing a YANG model. This parsing does not
-     * validate full YANG module, only parses header up to the revisions and imports.
-     *
-     * @param refClass Base search class
-     * @param resourceName resource name, relative to refClass
-     * @return {@link YangModelDependencyInfo}
-     * @throws YangSyntaxErrorException If the resource does not pass syntactic analysis
-     * @throws IOException When the resource cannot be read
-     * @throws IllegalArgumentException
-     *             If input stream is not valid YANG stream
-     * @deprecated This method was used by testing framework and was deemed to be potentially useful to the outside
-     *             world. With Java Platform Module System, though, the resource loading rules have changed to the point
-     *             where we no longer can guarantee it working correctly, as the results depend on the resource path.
-     *             Users are advised to use {@link #forYangText(YangTextSchemaSource)}.
-     */
-    @Deprecated(forRemoval = true)
-    public static YangModelDependencyInfo forResource(final Class<?> refClass, final String resourceName)
-            throws IOException, YangSyntaxErrorException {
-        return forYangText(YangTextSchemaSource.forResource(refClass, resourceName));
-    }
-
     /**
      * Extracts {@link YangModelDependencyInfo} from a {@link YangTextSchemaSource}. This parsing does not
      * validate full YANG module, only parses header up to the revisions and imports.
@@ -341,7 +318,10 @@ public abstract class YangModelDependencyInfo {
     static String safeStringArgument(final SourceIdentifier source, final IRStatement stmt, final String desc) {
         final StatementSourceReference ref = getReference(source, stmt);
         final IRArgument arg = stmt.argument();
-        checkArgument(arg != null, "Missing %s at %s", desc, ref);
+        if (arg == null) {
+            throw new IllegalArgumentException("Missing " + desc + " at " + ref);
+        }
+
         // TODO: we probably need to understand yang version first....
         return ArgumentContextUtils.rfc6020().stringFromStringContext(arg, ref);
     }
@@ -382,6 +362,8 @@ public abstract class YangModelDependencyInfo {
 
         /**
          * Returns name of parent module.
+         *
+         * @return The module this info belongs to
          */
         public String getParentModule() {
             return belongsTo;
@@ -411,7 +393,7 @@ public abstract class YangModelDependencyInfo {
 
         ModuleImportImpl(final @NonNull String moduleName, final @Nullable Revision revision,
                 final @Nullable SemVer semVer) {
-            this.name = requireNonNull(moduleName, "Module name must not be null.");
+            name = requireNonNull(moduleName, "Module name must not be null.");
             this.revision = revision;
             this.semVer = semVer;
         }
@@ -427,13 +409,14 @@ public abstract class YangModelDependencyInfo {
         }
 
         @Override
+        @Deprecated(forRemoval = true)
         public Optional<SemVer> getSemanticVersion() {
             return Optional.ofNullable(semVer);
         }
 
         @Override
         public String getPrefix() {
-            return null;
+            throw new UnsupportedOperationException();
         }
 
         @Override