BUG-4688: Rework SchemaContext module lookups
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / ModuleIdentifier.java
index a1e8b433c06a69c278ad925a1697e5eba72bdaff..67eed3ad303712eadb276cf7270ab9fb77988a6b 100644 (file)
@@ -5,27 +5,23 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.model.api;
 
-import java.net.URI;
 import java.util.Date;
+import java.util.Optional;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 
-
+/**
+ * Module identifier. This "identifier" is deprecated and is to be removed in 2.0.0.
+ * @author Robert Varga
+ *
+ * @deprecated Use {@link SourceIdentifier} instead.
+ */
+@Deprecated
 public interface ModuleIdentifier {
-
-    /**
-     * Returns the namespace of the module which is specified as argument of
-     * YANG {@link Module <b><font color="#00FF00">namespace</font></b>}
-     * keyword.
-     *
-     * @return URI format of the namespace of the module
-     */
-    URI getNamespace();
-
     /**
      * Returns the name of the module which is specified as argument of YANG
-     * {@link Module <b><font color="#FF0000">module</font></b>} keyword
+     * {@link Module <b><font color="#FF0000">module</font></b>} keyword.
      *
      * @return string with the name of the module
      */
@@ -38,5 +34,13 @@ public interface ModuleIdentifier {
      *         YANG {@link Module <b><font color="#339900">revison</font></b>}
      *         keyword
      */
-    Date getRevision();
+    // FIXME: BUG-4688: should return Optional<Revision>
+    Optional<Date> getRevision();
+
+    static int compareRevisions(final Optional<Date> first, final Optional<Date> second) {
+        if (!first.isPresent()) {
+            return second.isPresent() ? -1 : 0;
+        }
+        return second.isPresent() ? first.get().compareTo(second.get()) : 1;
+    }
 }