import static java.util.Objects.requireNonNull;
-import com.google.common.annotations.Beta;
import com.google.common.base.MoreObjects;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import java.io.Serial;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.cds.types.rev191024.ClientGeneration;
import org.opendaylight.yangtools.concepts.WritableIdentifier;
import org.opendaylight.yangtools.concepts.WritableObjects;
+import org.opendaylight.yangtools.yang.common.Uint64;
/**
* A cluster-wide unique identifier of a frontend instance. This identifier discerns between individual incarnations
*
* @author Robert Varga
*/
-@Beta
public final class ClientIdentifier implements WritableIdentifier {
private static final class Proxy implements Externalizable {
+ @Serial
private static final long serialVersionUID = 1L;
+
private FrontendIdentifier frontendId;
private long generation;
generation = WritableObjects.readLong(in);
}
+ @Serial
private Object readResolve() {
return new ClientIdentifier(frontendId, generation);
}
}
+ @Serial
private static final long serialVersionUID = 1L;
- private final FrontendIdentifier frontendId;
+
+ private final @NonNull FrontendIdentifier frontendId;
private final long generation;
ClientIdentifier(final FrontendIdentifier frontendId, final long generation) {
this.generation = generation;
}
- public static ClientIdentifier create(final FrontendIdentifier frontendId,
+ public static @NonNull ClientIdentifier create(final FrontendIdentifier frontendId,
final long generation) {
return new ClientIdentifier(frontendId, generation);
}
- public static ClientIdentifier readFrom(final DataInput in) throws IOException {
+ public static @NonNull ClientIdentifier readFrom(final DataInput in) throws IOException {
final FrontendIdentifier frontendId = FrontendIdentifier.readFrom(in);
return new ClientIdentifier(frontendId, WritableObjects.readLong(in));
}
WritableObjects.writeLong(out, generation);
}
- public FrontendIdentifier getFrontendId() {
+ public @NonNull FrontendIdentifier getFrontendId() {
return frontendId;
}
return generation;
}
+ public @NonNull ClientGeneration getYangGeneration() {
+ return new ClientGeneration(Uint64.fromLongBits(generation));
+ }
+
@Override
public int hashCode() {
return frontendId.hashCode() * 31 + Long.hashCode(generation);
@Override
public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (!(obj instanceof ClientIdentifier)) {
- return false;
- }
-
- final ClientIdentifier other = (ClientIdentifier) obj;
- return generation == other.generation && frontendId.equals(other.frontendId);
+ return this == obj || obj instanceof ClientIdentifier other && generation == other.generation
+ && frontendId.equals(other.frontendId);
}
@Override
public String toString() {
- return MoreObjects.toStringHelper(ClientIdentifier.class).add("frontend", frontendId)
- .add("generation", Long.toUnsignedString(generation)).toString();
+ return MoreObjects.toStringHelper(ClientIdentifier.class)
+ .add("frontend", frontendId)
+ .add("generation", Long.toUnsignedString(generation))
+ .toString();
}
+ @Serial
private Object writeReplace() {
return new Proxy(frontendId, generation);
}