TSK-646: Added equals and hash methods to TimeInterval

This commit is contained in:
julian.schallenmueller 2018-11-08 10:00:22 +01:00 committed by Holger Hagen
parent cc675e324b
commit ff558b3a2a
1 changed files with 38 additions and 0 deletions

View File

@ -62,4 +62,42 @@ public class TimeInterval {
return builder.toString();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((begin == null) ? 0 : begin.hashCode());
result = prime * result + ((end == null) ? 0 : end.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
TimeInterval other = (TimeInterval) obj;
if (begin == null) {
if (other.begin != null) {
return false;
}
} else if (!begin.equals(other.begin)) {
return false;
}
if (end == null) {
if (other.end != null) {
return false;
}
} else if (!end.equals(other.end)) {
return false;
}
return true;
}
}