Improve internal cast
[mdsal.git] / binding / yang-binding / src / main / java / org / opendaylight / yangtools / yang / binding / InstanceIdentifier.java
index d7edf405704af947a850da92e6803e7daca69006..416ce36b3d132f2f9664ace6cb0293579ecc9b53 100644 (file)
@@ -25,9 +25,7 @@ import java.util.Objects;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.concepts.Path;
+import org.opendaylight.yangtools.concepts.HierarchicalIdentifier;
 import org.opendaylight.yangtools.util.HashCodeBuilder;
 
 /**
@@ -61,8 +59,8 @@ import org.opendaylight.yangtools.util.HashCodeBuilder;
  * <p>
  * This would be the same as using a path like so, "/nodes/node/openflow:1" to refer to the openflow:1 node
  */
-public class InstanceIdentifier<T extends DataObject> implements Path<InstanceIdentifier<? extends DataObject>>,
-        Immutable, Serializable {
+public class InstanceIdentifier<T extends DataObject>
+        implements HierarchicalIdentifier<InstanceIdentifier<? extends DataObject>> {
     private static final long serialVersionUID = 3L;
 
     /*
@@ -539,9 +537,9 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
      *         contains a null element.
      */
     public static @NonNull InstanceIdentifier<?> create(final Iterable<? extends PathArgument> pathArguments) {
-        if (pathArguments instanceof ImmutableCollection<?>) {
+        if (pathArguments instanceof ImmutableCollection) {
             @SuppressWarnings("unchecked")
-            final Iterable<PathArgument> immutableArguments = (Iterable<PathArgument>) pathArguments;
+            final var immutableArguments = (ImmutableCollection<PathArgument>) pathArguments;
             return internalCreate(immutableArguments);
         }
 
@@ -828,7 +826,7 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
         }
     }
 
-    public interface InstanceIdentifierBuilder<T extends DataObject> extends Builder<InstanceIdentifier<T>> {
+    public interface InstanceIdentifierBuilder<T extends DataObject> {
         /**
          * Append the specified container as a child of the current InstanceIdentifier referenced by the builder. This
          * method should be used when you want to build an instance identifier by appending top-level elements, for
@@ -913,8 +911,7 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
          *
          * @return Resulting instance identifier.
          */
-        @Override
-        InstanceIdentifier<T> build();
+        @NonNull InstanceIdentifier<T> build();
     }
 
     private Object writeReplace() throws ObjectStreamException {