Yuta HIGUCHI

add hashCode, etc. to MessageSubject

Change-Id: I5c0185ea6bc8ab37fc5bade1c64cc30be6a79f9a
1 package org.onlab.onos.store.cluster.messaging; 1 package org.onlab.onos.store.cluster.messaging;
2 2
3 +import static com.google.common.base.Preconditions.checkNotNull;
4 +
5 +import java.util.Objects;
6 +
3 /** 7 /**
4 * Representation of a message subject. 8 * Representation of a message subject.
5 * Cluster messages have associated subjects that dictate how they get handled 9 * Cluster messages have associated subjects that dictate how they get handled
...@@ -10,7 +14,7 @@ public class MessageSubject { ...@@ -10,7 +14,7 @@ public class MessageSubject {
10 private final String value; 14 private final String value;
11 15
12 public MessageSubject(String value) { 16 public MessageSubject(String value) {
13 - this.value = value; 17 + this.value = checkNotNull(value);
14 } 18 }
15 19
16 public String value() { 20 public String value() {
...@@ -21,4 +25,24 @@ public class MessageSubject { ...@@ -21,4 +25,24 @@ public class MessageSubject {
21 public String toString() { 25 public String toString() {
22 return value; 26 return value;
23 } 27 }
28 +
29 + @Override
30 + public int hashCode() {
31 + return value.hashCode();
32 + }
33 +
34 + @Override
35 + public boolean equals(Object obj) {
36 + if (this == obj) {
37 + return true;
38 + }
39 + if (obj == null) {
40 + return false;
41 + }
42 + if (getClass() != obj.getClass()) {
43 + return false;
44 + }
45 + MessageSubject that = (MessageSubject) obj;
46 + return Objects.equals(this.value, that.value);
47 + }
24 } 48 }
......