added equals/hashCode for GateDTO that considers left and right MarkDTO as well as name and idAsString

This commit is contained in:
Axel Uhl committed 2015-07-15 16:22:15 +02:00
1 parent 19208aa6f4
commit 52cb82ce59
1 file changed
+43
@@ -27,4 +27,47 @@ public class GateDTO extends ControlPointDTO {
public Iterable<MarkDTO> getMarks() {
return Arrays.asList(left, right);
}
@Override
public int hashCode() {
final int prime = 31;
int result = prime * getIdAsString().hashCode() * getName().hashCode();
result = prime * result + ((left == null) ? 0 : left.hashCode());
result = prime * result + ((right == null) ? 0 : right.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
GateDTO other = (GateDTO) obj;
if (getIdAsString() == null) {
if (other.getIdAsString() != null)
return false;
} else if (!getIdAsString().equals(other.getIdAsString()))
return false;
if (getName() == null) {
if (other.getName() != null)
return false;
} else if (!getName().equals(other.getName()))
return false;
if (left == null) {
if (other.left != null)
return false;
} else if (!left.equals(other.left))
return false;
if (right == null) {
if (other.right != null)
return false;
} else if (!right.equals(other.right))
return false;
return true;
}
}