From 73453aeb378995618dc815de83472eb2fdbde9e0 Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Sat, 22 Jun 2024 10:37:27 +0200 Subject: [PATCH] Remove InstanceIdentifier.AbstractPathArgument This class hierarchy has been superseded by DataObjectStep, remove it. Change-Id: I524508035386ffa7c275a65753968921b0abec1a Signed-off-by: Robert Varga --- .../yang/binding/InstanceIdentifier.java | 187 +----------------- 1 file changed, 3 insertions(+), 184 deletions(-) diff --git a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java index 3a217f3f04..6b05f28e62 100644 --- a/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java +++ b/binding/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java @@ -23,10 +23,8 @@ import java.io.NotSerializableException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.ObjectStreamException; -import java.io.Serializable; import java.util.Collections; import java.util.List; -import java.util.Objects; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.opendaylight.yangtools.concepts.HierarchicalIdentifier; @@ -455,7 +453,7 @@ public sealed class InstanceIdentifier } /** - * Create a {@link Builder} for a specific type of InstanceIdentifier which represents an {@link IdentifiableItem}. + * Create a {@link Builder} for a specific type of InstanceIdentifier which represents an {@link KeyStep}. * * @param listItem list item class * @param listKey key value @@ -471,8 +469,8 @@ public sealed class InstanceIdentifier } /** - * Create a {@link Builder} for a specific type of InstanceIdentifier which represents an {@link IdentifiableItem} - * in a {@code grouping} used in the {@code case} statement. + * Create a {@link Builder} for a specific type of InstanceIdentifier which represents an {@link KeyStep} + * in a {@code grouping} used in the {@code case} statement. * * @param caze Choice case class * @param listItem list item class @@ -642,185 +640,6 @@ public sealed class InstanceIdentifier } } - @Deprecated(since = "13.0.0", forRemoval = true) - private abstract static sealed class AbstractPathArgument - implements Comparable>, Serializable { - @java.io.Serial - private static final long serialVersionUID = 1L; - - private final @NonNull Class type; - - AbstractPathArgument(final Class type) { - this.type = requireNonNull(type, "Type may not be null."); - } - - /** - * Return the data object type backing this PathArgument. - * - * @return Data object type. - */ - final @NonNull Class type() { - return type; - } - - /** - * Return an optional enclosing case type. This is used only when {@link #type()} references a node defined - * in a {@code grouping} which is reference inside a {@code case} statement in order to safely reference the - * node. - * - * @return case class or {@code null} - */ - Class caseType() { - return null; - } - - @Nullable Object key() { - return null; - } - - @Override - public final int hashCode() { - return Objects.hash(type, caseType(), key()); - } - - @Override - public final boolean equals(final Object obj) { - return this == obj || obj instanceof AbstractPathArgument other && type.equals(other.type) - && Objects.equals(key(), other.key()) && Objects.equals(caseType(), other.caseType()); - } - - @Override - public final int compareTo(final AbstractPathArgument arg) { - final int cmp = compareClasses(type, arg.type()); - if (cmp != 0) { - return cmp; - } - final var caseType = caseType(); - final var argCaseType = arg.caseType(); - if (caseType == null) { - return argCaseType == null ? 1 : -1; - } - return argCaseType == null ? 1 : compareClasses(caseType, argCaseType); - } - - private static int compareClasses(final Class first, final Class second) { - return first.getCanonicalName().compareTo(second.getCanonicalName()); - } - - @java.io.Serial - final Object readResolve() throws ObjectStreamException { - return toStep(); - } - - abstract DataObjectStep toStep(); - } - - /** - * An Item represents an object that probably is only one of it's kind. For example a Nodes object is only one of - * a kind. In YANG terms this would probably represent a container. - * - * @param Item type - */ - @Deprecated(since = "13.0.0", forRemoval = true) - private static sealed class Item extends AbstractPathArgument { - @java.io.Serial - private static final long serialVersionUID = 1L; - - Item(final Class type) { - super(type); - } - - @Override - @SuppressWarnings({ "rawtypes", "unchecked" }) - final DataObjectStep toStep() { - return createStep((Class) caseType(), type()); - } - - @Override - public String toString() { - return type().getName(); - } - } - - /** - * An IdentifiableItem represents a object that is usually present in a collection and can be identified uniquely - * by a key. In YANG terms this would probably represent an item in a list. - * - * @param An object that is identifiable by an identifier - * @param The identifier of the object - */ - @Deprecated(since = "13.0.0", forRemoval = true) - private static sealed class IdentifiableItem & DataObject, T extends Key> - extends AbstractPathArgument { - @java.io.Serial - private static final long serialVersionUID = 1L; - - private final @NonNull T key; - - IdentifiableItem(final Class type, final T key) { - super(type); - this.key = requireNonNull(key, "Key may not be null."); - } - - /** - * Return the data object type backing this PathArgument. - * - * @return Data object type. - */ - @Override - final @NonNull T key() { - return key; - } - - @Override - final KeyStep toStep() { - return new KeyStep<>(type(), caseType(), key); - } - - @Override - public String toString() { - return type().getName() + "[key=" + key + "]"; - } - } - - @Deprecated(since = "13.0.0", forRemoval = true) - private static final class CaseItem & DataObject, T extends ChildOf> - extends Item { - @java.io.Serial - private static final long serialVersionUID = 1L; - - private final Class caseType; - - CaseItem(final Class caseType, final Class type) { - super(type); - this.caseType = requireNonNull(caseType); - } - - @Override - Class caseType() { - return caseType; - } - } - - @Deprecated(since = "13.0.0", forRemoval = true) - private static final class CaseIdentifiableItem & DataObject, - T extends ChildOf & KeyAware, K extends Key> extends IdentifiableItem { - @java.io.Serial - private static final long serialVersionUID = 1L; - - private final Class caseType; - - CaseIdentifiableItem(final Class caseType, final Class type, final K key) { - super(type, key); - this.caseType = requireNonNull(caseType); - } - - @Override - Class caseType() { - return caseType; - } - } - /** * A builder of {@link InstanceIdentifier} objects. * -- 2.36.6