package org.opendaylight.yangtools.yang.binding;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import java.io.Externalizable;
import java.io.IOException;
+import java.io.NotSerializableException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.ObjectStreamException;
import java.io.Serial;
-import java.util.ArrayList;
-import java.util.List;
import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
class InstanceIdentifierV3<T extends DataObject> implements Externalizable {
@Serial
private static final long serialVersionUID = 3L;
- private @Nullable Iterable<PathArgument> pathArguments;
+ private @Nullable Iterable<DataObjectStep<?>> pathArguments;
private @Nullable Class<T> targetType;
private boolean wildcarded;
private int hash;
// For Externalizable
}
- InstanceIdentifierV3(final InstanceIdentifier<T> source) {
- pathArguments = source.pathArguments;
- targetType = source.getTargetType();
- wildcarded = source.isWildcarded();
- hash = source.hashCode();
- }
-
final int getHash() {
return hash;
}
- final Iterable<PathArgument> getPathArguments() {
+ final Iterable<DataObjectStep<?>> getPathArguments() {
return pathArguments;
}
@Override
public void writeExternal(final ObjectOutput out) throws IOException {
- out.writeObject(targetType);
- out.writeBoolean(wildcarded);
- out.writeInt(hash);
- out.writeInt(Iterables.size(pathArguments));
- for (Object o : pathArguments) {
- out.writeObject(o);
- }
+ throw new NotSerializableException(InstanceIdentifierV3.class.getName());
}
@Override
hash = in.readInt();
final int size = in.readInt();
- final List<PathArgument> args = new ArrayList<>();
+ final var builder = ImmutableList.<DataObjectStep<?>>builderWithExpectedSize(size);
for (int i = 0; i < size; ++i) {
- args.add((PathArgument) in.readObject());
+ builder.add((DataObjectStep<?>) in.readObject());
}
- pathArguments = ImmutableList.copyOf(args);
+ pathArguments = builder.build();
}
- @Serial
+ @java.io.Serial
Object readResolve() throws ObjectStreamException {
return new InstanceIdentifier<>(targetType, pathArguments, wildcarded, hash);
}