X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=model%2Fyang-model-api%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Fapi%2FSchemaPath.java;h=5096b286c0ba8616a8d9b0b001f9ef6867297707;hb=32aeb53bf28c97c1a47b8e5c4eb2f211fdc92c58;hp=60d7f71739a524f0f5cd763a330fe48f4132538d;hpb=b67b827e357ae40ae26e4bfec35b76ef5ee67967;p=yangtools.git diff --git a/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaPath.java b/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaPath.java index 60d7f71739..5096b286c0 100644 --- a/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaPath.java +++ b/model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/SchemaPath.java @@ -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: + * + * 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. *