SchemaNodeIdentifier depends on SchemaPath, which is a bad idea from
flexibility perspective. Since the methods are deprecated, add their
non-cached counterparts in SchemaPath.
JIRA: YANGTOOLS-1358
Change-Id: I8fc6897940a172b06cf309f1a40b56e4e00a6030
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
4cea93f6402296296b1a0551241eaa4e16ae6f03)
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.
*
* Create the {@link SchemaPath} equivalent of this identifier.
*
* @return SchemaPath equivalent.
- * @deprecated This method is scheduled for removal along with {@link SchemaPath}.
+ * @deprecated This method is scheduled for removal along with {@link SchemaPath}. This method performs memoization,
+ * which should not be needed most of the time. If you need memoization, you probably can do better, as
+ * you probably want to attach more state. If you just need a SchemaPath, use
+ * {@link SchemaPath#of(SchemaNodeIdentifier)} instead.
*/
@Deprecated(since = "7.0.9", forRemoval = true)
public final @NonNull SchemaPath asSchemaPath() {