Pick up byte-buddy from yangtools
[mdsal.git] / binding / yang-binding / src / main / java / org / opendaylight / yangtools / yang / binding / KeyedInstanceIdentifierV2.java
index fbce0dee8d8fac923a9a147a7f22519312986d70..a9f718298d5440d564a5759fd231f53ec3c722eb 100644 (file)
@@ -11,24 +11,20 @@ import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.io.ObjectStreamException;
-import org.eclipse.jdt.annotation.Nullable;
+import java.io.Serial;
 
-final class KeyedInstanceIdentifierV2<T extends Identifiable<K> & DataObject, K extends Identifier<T>>
+final class KeyedInstanceIdentifierV2<T extends KeyAware<K> & DataObject, K extends Key<T>>
         extends InstanceIdentifierV3<T> {
+    @java.io.Serial
     private static final long serialVersionUID = 2L;
 
-    private @Nullable K key;
+    private K key;
 
     @SuppressWarnings("redundantModifier")
     public KeyedInstanceIdentifierV2() {
         // For Externalizable
     }
 
-    KeyedInstanceIdentifierV2(final KeyedInstanceIdentifier<T, K> source) {
-        super(source);
-        key = source.getKey();
-    }
-
     @Override
     public void writeExternal(final ObjectOutput out) throws IOException {
         super.writeExternal(out);
@@ -41,7 +37,10 @@ final class KeyedInstanceIdentifierV2<T extends Identifiable<K> & DataObject, K
         key = (K) in.readObject();
     }
 
-    private Object readResolve() throws ObjectStreamException {
-        return new KeyedInstanceIdentifier<>(getTargetType(), getPathArguments(), isWildcarded(), getHash(), key);
+    @Serial
+    @Override
+    Object readResolve() throws ObjectStreamException {
+        return new KeyedInstanceIdentifier<>(new KeyStep<>(getTargetType(), key), getPathArguments(),
+            isWildcarded(), getHash());
     }
 }