1
0
Fork 0
mirror of https://github.com/graphhopper/jsprit.git synced 2020-01-24 07:45:05 +01:00

generated hashcode and equals in core.problem.vehicle.VehicleImpl such

that two vehicles are equal if they have the same id and if their types
are equal
This commit is contained in:
Stefan Schroeder 2014-06-26 10:58:42 +02:00
parent 2a36ed42cf
commit be5918a67d
3 changed files with 74 additions and 2 deletions

View file

@ -330,5 +330,45 @@ public class VehicleImpl implements Vehicle {
public Coordinate getEndLocationCoordinate() {
return this.endLocationCoord;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
/**
* Two vehicles are equal if they have the same id and if their types are equal.
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
VehicleImpl other = (VehicleImpl) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
return true;
}
}