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);
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());
}
}