2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.binding;
10 import com.google.common.collect.ImmutableList;
11 import java.io.Externalizable;
12 import java.io.IOException;
13 import java.io.NotSerializableException;
14 import java.io.ObjectInput;
15 import java.io.ObjectOutput;
16 import java.io.ObjectStreamException;
17 import java.io.Serial;
18 import org.eclipse.jdt.annotation.Nullable;
20 class InstanceIdentifierV3<T extends DataObject> implements Externalizable {
22 private static final long serialVersionUID = 3L;
24 private @Nullable Iterable<DataObjectStep<?>> pathArguments;
25 private @Nullable Class<T> targetType;
26 private boolean wildcarded;
29 @SuppressWarnings("redundantModifier")
30 public InstanceIdentifierV3() {
38 final Iterable<DataObjectStep<?>> getPathArguments() {
42 final Class<T> getTargetType() {
46 final boolean isWildcarded() {
51 public void writeExternal(final ObjectOutput out) throws IOException {
52 throw new NotSerializableException(InstanceIdentifierV3.class.getName());
56 public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
57 targetType = (Class<T>) in.readObject();
58 wildcarded = in.readBoolean();
61 final int size = in.readInt();
62 final var builder = ImmutableList.<DataObjectStep<?>>builderWithExpectedSize(size);
63 for (int i = 0; i < size; ++i) {
64 builder.add((DataObjectStep<?>) in.readObject());
66 pathArguments = builder.build();
70 Object readResolve() throws ObjectStreamException {
71 return new InstanceIdentifier<>(targetType, pathArguments, wildcarded, hash);