Fix Socket's equals method
@@ -20,7 +20,7 @@ public class Socket {
@Convert(converter = URIConverter.class)
private URI typeURI;
/* The uri of the socket - must be defined in the atom's content */
- @Column(name = "socketURI")
+ @Column(name = "socketURI", nullable = false)
@Convert(converter = URIConverter.class)
private URI socketURI;
@Column(name = "defaultSocket")
@@ -64,24 +64,27 @@ public class Socket {
}
@Override
- public boolean equals(Object o) {
- if (this == o)
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((socketURI == null) ? 0 : socketURI.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
return true;
- if (o == null || getClass() != o.getClass())
+ if (obj == null)
return false;
- Socket socket = (Socket) o;
- if (!Objects.equals(id, socket.id))
+ if (getClass() != obj.getClass())
return false;
- if (!Objects.equals(atomURI, socket.atomURI))
+ Socket other = (Socket) obj;
+ if (socketURI == null) {
+ if (other.socketURI != null)
return false;
- return Objects.equals(typeURI, socket.typeURI);
- }
-
- @Override
- public int hashCode() {
- int result = id != null ? id.hashCode() : 0;
- result = 31 * result + (atomURI != null ? atomURI.hashCode() : 0);
- result = 31 * result + (typeURI != null ? typeURI.hashCode() : 0);
- return result;
+ } else if (!socketURI.equals(other.socketURI))
+ return false;
+ return true;
}
}
