Remove SchemaNodeIdentifier.asSchemaPath() 51/98151/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Oct 2021 00:18:00 +0000 (02:18 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 27 Oct 2021 07:42:40 +0000 (09:42 +0200)
Disconnect SchemaNodeIdentifier from SchemaPath. The replacement
lives as SchemaPath.of() family of methods.

Change-Id: Ia1e41eb412c0f80562ae38354b7cd7bc7a238366
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
model/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/SchemaNodeIdentifier.java

index 5c74fdc9aebde7574ab5017505d0b9e6389d2e31..b5f9be9e8d05096033158d50eeb47e3b7acab827 100644 (file)
@@ -19,12 +19,10 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
-import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 /**
  * Represents unique path to every schema node inside the schema node identifier namespace. This concept is defined
@@ -86,12 +84,6 @@ public abstract class SchemaNodeIdentifier implements Immutable {
             return INTERNER.intern(this);
         }
 
-        @Override
-        @Deprecated(since = "7.0.9", forRemoval = true)
-        final SchemaPath implicitSchemaPathParent() {
-            return SchemaPath.ROOT;
-        }
-
         @Override
         final String className() {
             return "Absolute";
@@ -142,12 +134,6 @@ public abstract class SchemaNodeIdentifier implements Immutable {
             return qnames.size() == 1 ? of(qnames.get(0)) : new DescandantMultiple(qnames);
         }
 
-        @Override
-        @Deprecated(since = "7.0.9", forRemoval = true)
-        final SchemaPath implicitSchemaPathParent() {
-            return SchemaPath.SAME;
-        }
-
         @Override
         final String className() {
             return "Descendant";
@@ -246,13 +232,6 @@ public abstract class SchemaNodeIdentifier implements Immutable {
         }
     }
 
-    @Deprecated(since = "7.0.9", forRemoval = true)
-    private static final AtomicReferenceFieldUpdater<SchemaNodeIdentifier, SchemaPath> SCHEMAPATH_UPDATER =
-            AtomicReferenceFieldUpdater.newUpdater(SchemaNodeIdentifier.class, SchemaPath.class, "schemaPath");
-
-    // Cached SchemaPath.
-    @Deprecated(since = "7.0.9", forRemoval = true)
-    private volatile SchemaPath schemaPath;
     // Cached hashCode
     private volatile int hash;
 
@@ -288,21 +267,6 @@ public abstract class SchemaNodeIdentifier implements Immutable {
         return local.get(local.size() - 1);
     }
 
-    /**
-     * Create the {@link SchemaPath} equivalent of this identifier.
-     *
-     * @return SchemaPath equivalent.
-     * @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() {
-        final SchemaPath ret = schemaPath;
-        return ret != null ? ret : loadSchemaPath();
-    }
-
     @Override
     public final int hashCode() {
         final int local;
@@ -320,19 +284,10 @@ public abstract class SchemaNodeIdentifier implements Immutable {
         return MoreObjects.toStringHelper(className()).add("qnames", toStringQNames()).toString();
     }
 
-    @Deprecated(since = "7.0.9", forRemoval = true)
-    abstract @NonNull SchemaPath implicitSchemaPathParent();
-
     abstract @NonNull Object pathObject();
 
     abstract @NonNull String className();
 
-    @Deprecated(since = "7.0.9", forRemoval = true)
-    private @NonNull SchemaPath loadSchemaPath() {
-        final SchemaPath newPath = implicitSchemaPathParent().createChild(getNodeIdentifiers());
-        return SCHEMAPATH_UPDATER.compareAndSet(this, null, newPath) ? newPath : schemaPath;
-    }
-
     private List<?> toStringQNames() {
         final List<QName> ids = getNodeIdentifiers();
         return ids.size() < 2 ? ids : simplifyQNames(ids);