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

Merge pull request #383 from michalmac/master

Shipment.toString() added
This commit is contained in:
Stefan Schröder 2017-10-26 11:26:10 +02:00 committed by GitHub
commit 0aa61bd8aa
3 changed files with 35 additions and 17 deletions

View file

@ -93,7 +93,9 @@ public class Service extends AbstractJob {
private int priority = 2; private int priority = 2;
protected Object userData; protected Object userData;
protected double maxTimeInVehicle = Double.MAX_VALUE;Builder(String id){ protected double maxTimeInVehicle = Double.MAX_VALUE;
Builder(String id){
this.id = id; this.id = id;
timeWindows = new TimeWindowsImpl(); timeWindows = new TimeWindowsImpl();
timeWindows.add(timeWindow); timeWindows.add(timeWindow);
@ -266,8 +268,6 @@ public class Service extends AbstractJob {
private final double serviceTime; private final double serviceTime;
private final TimeWindow timeWindow;
private final Capacity size; private final Capacity size;
private final Skills skills; private final Skills skills;
@ -276,7 +276,7 @@ public class Service extends AbstractJob {
private final Location location; private final Location location;
private final TimeWindows timeWindowManager; private final TimeWindows timeWindows;
private final int priority; private final int priority;
@ -286,18 +286,18 @@ public class Service extends AbstractJob {
setUserData(builder.userData); setUserData(builder.userData);
id = builder.id; id = builder.id;
serviceTime = builder.serviceTime; serviceTime = builder.serviceTime;
timeWindow = builder.timeWindow;
type = builder.type; type = builder.type;
size = builder.capacity; size = builder.capacity;
skills = builder.skills; skills = builder.skills;
name = builder.name; name = builder.name;
location = builder.location; location = builder.location;
timeWindowManager = builder.timeWindows; timeWindows = builder.timeWindows;
priority = builder.priority; priority = builder.priority;
maxTimeInVehicle = builder.maxTimeInVehicle;} maxTimeInVehicle = builder.maxTimeInVehicle;
}
public Collection<TimeWindow> getTimeWindows(){ public Collection<TimeWindow> getTimeWindows(){
return timeWindowManager.getTimeWindows(); return timeWindows.getTimeWindows();
} }
@Override @Override
@ -332,7 +332,7 @@ public class Service extends AbstractJob {
* *
*/ */
public TimeWindow getTimeWindow() { public TimeWindow getTimeWindow() {
return timeWindowManager.getTimeWindows().iterator().next(); return timeWindows.getTimeWindows().iterator().next();
} }
/** /**
@ -349,10 +349,11 @@ public class Service extends AbstractJob {
*/ */
@Override @Override
public String toString() { public String toString() {
return "[id=" + id + "][name=" + name + "][type=" + type + "][location=" + location + "][capacity=" + size + "][serviceTime=" + serviceTime + "][timeWindow=" + timeWindow + "]"; return "[id=" + id + "][name=" + name + "][type=" + type + "][location=" + location
+ "][capacity=" + size + "][serviceTime=" + serviceTime + "][timeWindows="
+ timeWindows + "]";
} }
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;

View file

@ -349,10 +349,6 @@ public class Shipment extends AbstractJob {
private final double deliveryServiceTime; private final double deliveryServiceTime;
private final TimeWindow deliveryTimeWindow;
private final TimeWindow pickupTimeWindow;
private final Capacity capacity; private final Capacity capacity;
private final Skills skills; private final Skills skills;
@ -375,9 +371,7 @@ public class Shipment extends AbstractJob {
setUserData(builder.userData); setUserData(builder.userData);
this.id = builder.id; this.id = builder.id;
this.pickupServiceTime = builder.pickupServiceTime; this.pickupServiceTime = builder.pickupServiceTime;
this.pickupTimeWindow = builder.pickupTimeWindow;
this.deliveryServiceTime = builder.deliveryServiceTime; this.deliveryServiceTime = builder.deliveryServiceTime;
this.deliveryTimeWindow = builder.deliveryTimeWindow;
this.capacity = builder.capacity; this.capacity = builder.capacity;
this.skills = builder.skills; this.skills = builder.skills;
this.name = builder.name; this.name = builder.name;
@ -448,6 +442,21 @@ public class Shipment extends AbstractJob {
return pickupTimeWindows.getTimeWindows(); return pickupTimeWindows.getTimeWindows();
} }
/**
* Returns a string with the shipment's attributes.
* <p>
* <p>String is built as follows: [attr1=val1][attr2=val2]...
*/
@Override
public String toString() {
return "[id=" + id + "][name=" + name + "][pickupLocation=" + pickupLocation_
+ "][deliveryLocation=" + deliveryLocation_ + "][capacity=" + capacity
+ "][pickupServiceTime=" + pickupServiceTime + "][deliveryServiceTime="
+ deliveryServiceTime + "][pickupTimeWindows=" + pickupTimeWindows
+ "][deliveryTimeWindows=" + deliveryTimeWindows + "]";
}
@Override @Override
public int hashCode() { public int hashCode() {

View file

@ -48,4 +48,12 @@ public class TimeWindowsImpl implements TimeWindows {
return Collections.unmodifiableCollection(timeWindows); return Collections.unmodifiableCollection(timeWindows);
} }
@Override
public String toString() {
StringBuffer sb = new StringBuffer(timeWindows.size() * 60);
for (TimeWindow tw : timeWindows) {
sb.append("[timeWindow=").append(tw).append("]");
}
return sb.toString();
}
} }