Eliminate HelperMethods
[yangtools.git] / model / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / SchemaPath.java
index 60d7f71739a524f0f5cd763a330fe48f4132538d..5096b286c0ba8616a8d9b0b001f9ef6867297707 100644 (file)
@@ -28,7 +28,20 @@ import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Desce
 
 /**
  * Represents unique path to the every node inside the module.
+ *
+ * @deprecated This path is not really unique, as it does not handle YANG namespace overlap correctly. There are two
+ *             different replacements for this class:
+ *             <ul>
+ *               <li>{@link SchemaNodeIdentifier} for use in
+ *                   <a href="https://datatracker.ietf.org/doc/html/rfc7950#section-6.5">YANG schema addressing</a>
+ *                   contexts</li>
+ *               <li>{@link EffectiveStatementInference} for use in contexts where the intent is to exchange pointer
+ *                   to a specific statement. Unlike SchemaPath, though, it does not require additional lookup in most
+ *                   cases</li>
+ *             </ul>
+ *             This class is scheduled for removal in the next major release.
  */
+@Deprecated(since = "7.0.8", forRemoval = true)
 public abstract class SchemaPath implements Immutable {
 
     /**
@@ -106,6 +119,24 @@ public abstract class SchemaPath implements Immutable {
         hash = tmp;
     }
 
+    public static @NonNull SchemaPath of(final SchemaNodeIdentifier path) {
+        if (path instanceof Absolute) {
+            return of((Absolute) path);
+        } else if (path instanceof Descendant) {
+            return of((Descendant) path);
+        } else {
+            throw new IllegalStateException("Unexpected path " + requireNonNull(path));
+        }
+    }
+
+    public static @NonNull SchemaPath of(final Absolute path) {
+        return SchemaPath.ROOT.createChild(path.getNodeIdentifiers());
+    }
+
+    public static @NonNull SchemaPath of(final Descendant path) {
+        return SchemaPath.SAME.createChild(path.getNodeIdentifiers());
+    }
+
     /**
      * Constructs new instance of this class with the concrete path.
      *