blob: 9735fdb1dbefabdb33cc92da2d059ae37fdc5bfc [file] [log] [blame]
tome4729872014-09-23 00:37:37 -07001package org.onlab.onos.cluster;
2
3import org.onlab.packet.IpPrefix;
4
5import java.util.Objects;
6
7import static com.google.common.base.MoreObjects.toStringHelper;
8
9/**
10 * Default implementation of a controller instance descriptor.
11 */
12public class DefaultControllerNode implements ControllerNode {
13
14 private final NodeId id;
15 private final IpPrefix ip;
16
17 /**
18 * Creates a new instance with the specified id and IP address.
19 *
20 * @param id instance identifier
21 * @param ip instance IP address
22 */
23 public DefaultControllerNode(NodeId id, IpPrefix ip) {
24 this.id = id;
25 this.ip = ip;
26 }
27
28 @Override
29 public NodeId id() {
30 return id;
31 }
32
33 @Override
34 public IpPrefix ip() {
35 return ip;
36 }
37
38 @Override
39 public int hashCode() {
40 return Objects.hash(id);
41 }
42
43 @Override
44 public boolean equals(Object o) {
45 if (this == o) {
46 return true;
47 }
48 if (o instanceof DefaultControllerNode) {
49 DefaultControllerNode that = (DefaultControllerNode) o;
50 return Objects.equals(this.id, that.id);
51 }
52 return false;
53 }
54
55 @Override
56 public String toString() {
57 return toStringHelper(this).add("id", id).add("ip", ip).toString();
58 }
59
60}