2 * Copyright (c) 2016 Cisco Systems, Inc. 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.controller.cluster.access.concepts;
10 import static java.util.Objects.requireNonNull;
12 import java.io.DataInput;
13 import java.io.DataOutput;
14 import java.io.IOException;
15 import java.util.Objects;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.opendaylight.yangtools.concepts.WritableIdentifier;
20 * A cluster-wide unique identifier of a frontend type located at a cluster member.
22 public final class FrontendIdentifier implements WritableIdentifier {
24 private static final long serialVersionUID = 1L;
26 private final MemberName memberName;
27 private final FrontendType clientType;
29 FrontendIdentifier(final MemberName memberName, final FrontendType clientType) {
30 this.clientType = requireNonNull(clientType);
31 this.memberName = requireNonNull(memberName);
34 public static @NonNull FrontendIdentifier create(final MemberName memberName, final FrontendType clientType) {
35 return new FrontendIdentifier(memberName, clientType);
38 public static @NonNull FrontendIdentifier readFrom(final DataInput in) throws IOException {
39 final var memberName = MemberName.readFrom(in);
40 final var clientType = FrontendType.readFrom(in);
41 return new FrontendIdentifier(memberName, clientType);
45 public void writeTo(final DataOutput out) throws IOException {
46 memberName.writeTo(out);
47 clientType.writeTo(out);
50 public @NonNull FrontendType getClientType() {
54 public @NonNull MemberName getMemberName() {
59 public int hashCode() {
60 return Objects.hash(memberName, clientType);
64 public boolean equals(final Object obj) {
65 return this == obj || obj instanceof FrontendIdentifier other && memberName.equals(other.memberName)
66 && clientType.equals(other.clientType);
69 public @NonNull String toPersistentId() {
70 return memberName.getName() + "-frontend-" + clientType.getName();
74 public String toString() {
75 return toPersistentId();
79 private Object writeReplace() {