blob: 50cdda450bc30b5961564c905be2ecc9323b1f6b [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
tom73d6d1e2014-09-17 20:08:01 -070016package org.onlab.onos.cluster;
17
tomfc9a4ff2014-09-22 18:22:47 -070018import java.util.Objects;
19
tom73d6d1e2014-09-17 20:08:01 -070020/**
21 * Controller cluster identity.
22 */
tome4729872014-09-23 00:37:37 -070023public class NodeId {
tomfc9a4ff2014-09-22 18:22:47 -070024
25 private final String id;
26
tomfc9a4ff2014-09-22 18:22:47 -070027 /**
tome4729872014-09-23 00:37:37 -070028 * Creates a new cluster node identifier from the specified string.
tomfc9a4ff2014-09-22 18:22:47 -070029 *
30 * @param id string identifier
31 */
tome4729872014-09-23 00:37:37 -070032 public NodeId(String id) {
tomfc9a4ff2014-09-22 18:22:47 -070033 this.id = id;
34 }
35
36 @Override
37 public int hashCode() {
38 return Objects.hash(id);
39 }
40
41 @Override
42 public boolean equals(Object obj) {
43 if (this == obj) {
44 return true;
45 }
tome4729872014-09-23 00:37:37 -070046 if (obj instanceof NodeId) {
47 final NodeId other = (NodeId) obj;
tomfc9a4ff2014-09-22 18:22:47 -070048 return Objects.equals(this.id, other.id);
49 }
50 return false;
51 }
52
53 @Override
54 public String toString() {
tome4729872014-09-23 00:37:37 -070055 return id;
tomfc9a4ff2014-09-22 18:22:47 -070056 }
57
tom73d6d1e2014-09-17 20:08:01 -070058}