mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
changed visibility and added toString to
core.problem.vehicle.VehicleTypeKey
This commit is contained in:
parent
daaadbc8de
commit
c3514dbf23
1 changed files with 25 additions and 8 deletions
|
|
@ -9,37 +9,40 @@ package jsprit.core.problem.vehicle;
|
|||
* @author stefan
|
||||
*
|
||||
*/
|
||||
class VehicleTypeKey {
|
||||
public class VehicleTypeKey {
|
||||
|
||||
public final String type;
|
||||
public final String startLocationId;
|
||||
public final String endLocationId;
|
||||
public final double earliestStart;
|
||||
public final double latestEnd;
|
||||
|
||||
VehicleTypeKey(String typeId, String startLocationId, String endLocationId) {
|
||||
public VehicleTypeKey(String typeId, String startLocationId, String endLocationId, double earliestStart, double latestEnd) {
|
||||
super();
|
||||
this.type = typeId;
|
||||
this.startLocationId = startLocationId;
|
||||
this.endLocationId = endLocationId;
|
||||
this.earliestStart = earliestStart;
|
||||
this.latestEnd = latestEnd;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(earliestStart);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
result = prime * result
|
||||
+ ((endLocationId == null) ? 0 : endLocationId.hashCode());
|
||||
temp = Double.doubleToLongBits(latestEnd);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
result = prime * result
|
||||
+ ((startLocationId == null) ? 0 : startLocationId.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
|
|
@ -49,11 +52,17 @@ class VehicleTypeKey {
|
|||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
VehicleTypeKey other = (VehicleTypeKey) obj;
|
||||
if (Double.doubleToLongBits(earliestStart) != Double
|
||||
.doubleToLongBits(other.earliestStart))
|
||||
return false;
|
||||
if (endLocationId == null) {
|
||||
if (other.endLocationId != null)
|
||||
return false;
|
||||
} else if (!endLocationId.equals(other.endLocationId))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(latestEnd) != Double
|
||||
.doubleToLongBits(other.latestEnd))
|
||||
return false;
|
||||
if (startLocationId == null) {
|
||||
if (other.startLocationId != null)
|
||||
return false;
|
||||
|
|
@ -67,6 +76,14 @@ class VehicleTypeKey {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(type).append("_").append(startLocationId).append("_").append(endLocationId)
|
||||
.append("_").append(Double.toString(earliestStart)).append("_").append(Double.toString(latestEnd));
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue