Yuta HIGUCHI

add equals, hashCode to VersionedValue

Change-Id: I41b981bb26fe252bfde8bc0b25e7454d5bfbe188
1 package org.onlab.onos.store.device.impl; 1 package org.onlab.onos.store.device.impl;
2 2
3 +import java.util.Objects;
4 +
3 import org.onlab.onos.store.Timestamp; 5 import org.onlab.onos.store.Timestamp;
4 6
5 /** 7 /**
...@@ -44,6 +46,29 @@ public class VersionedValue<T> { ...@@ -44,6 +46,29 @@ public class VersionedValue<T> {
44 } 46 }
45 47
46 48
49 + @Override
50 + public int hashCode() {
51 + return Objects.hash(entity, timestamp, isUp);
52 + }
53 +
54 + @Override
55 + public boolean equals(Object obj) {
56 + if (this == obj) {
57 + return true;
58 + }
59 + if (obj == null) {
60 + return false;
61 + }
62 + if (getClass() != obj.getClass()) {
63 + return false;
64 + }
65 + @SuppressWarnings("unchecked")
66 + VersionedValue<T> that = (VersionedValue<T>) obj;
67 + return Objects.equals(this.entity, that.entity) &&
68 + Objects.equals(this.timestamp, that.timestamp) &&
69 + Objects.equals(this.isUp, that.isUp);
70 + }
71 +
47 // Default constructor for serializer 72 // Default constructor for serializer
48 protected VersionedValue() { 73 protected VersionedValue() {
49 this.entity = null; 74 this.entity = null;
......