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

refine error messages

This commit is contained in:
oblonski 2017-11-28 15:47:33 +01:00 committed by Michal Maciejewski
parent 86b914d174
commit 369139211d

View file

@ -145,7 +145,7 @@ public class VehicleImpl extends AbstractVehicle {
* @throws IllegalArgumentException if type is null * @throws IllegalArgumentException if type is null
*/ */
public Builder setType(VehicleType type) { public Builder setType(VehicleType type) {
if (type == null) throw new IllegalArgumentException("type cannot be null."); if (type == null) throw new IllegalArgumentException("Vehicle type must not be null.");
this.type = type; this.type = type;
return this; return this;
} }
@ -213,7 +213,7 @@ public class VehicleImpl extends AbstractVehicle {
*/ */
public Builder setEarliestStart(double earliest_startTime) { public Builder setEarliestStart(double earliest_startTime) {
if (earliest_startTime < 0) if (earliest_startTime < 0)
throw new IllegalArgumentException("earliest start of vehicle " + id + " must not be negative"); throw new IllegalArgumentException("The earliest start time of vehicle " + id + " must not be negative.");
this.earliestStart = earliest_startTime; this.earliestStart = earliest_startTime;
return this; return this;
} }
@ -226,7 +226,7 @@ public class VehicleImpl extends AbstractVehicle {
*/ */
public Builder setLatestArrival(double latest_arrTime) { public Builder setLatestArrival(double latest_arrTime) {
if (latest_arrTime < 0) if (latest_arrTime < 0)
throw new IllegalArgumentException("latest arrival time of vehicle " + id + " must not be negative"); throw new IllegalArgumentException("The latest arrival time of vehicle " + id + " must not be negative.");
this.latestArrival = latest_arrTime; this.latestArrival = latest_arrTime;
return this; return this;
} }
@ -254,17 +254,17 @@ public class VehicleImpl extends AbstractVehicle {
*/ */
public VehicleImpl build() { public VehicleImpl build() {
if (latestArrival < earliestStart) if (latestArrival < earliestStart)
throw new IllegalArgumentException("latest arrival of vehicle " + id + " must not be smaller than its start time"); throw new IllegalArgumentException("The latest arrival time of vehicle " + id + " must not be smaller than its start time.");
if (startLocation != null && endLocation != null) { if (startLocation != null && endLocation != null) {
if (!startLocation.getId().equals(endLocation.getId()) && !returnToDepot) if (!startLocation.getId().equals(endLocation.getId()) && !returnToDepot)
throw new IllegalArgumentException("this must not be. you specified both endLocationId and open-routes. this is contradictory. <br>" + throw new IllegalArgumentException("You specified both the end location and that the vehicle " + id + " does not need to return to its end location. This must not be. " +
"if you set endLocation, returnToDepot must be true. if returnToDepot is false, endLocationCoord must not be specified."); "Either specify end location and return to depot or leave end location unspecified.");
} }
if (startLocation != null && endLocation == null) { if (startLocation != null && endLocation == null) {
endLocation = startLocation; endLocation = startLocation;
} }
if (startLocation == null && endLocation == null) if (startLocation == null && endLocation == null)
throw new IllegalArgumentException("vehicle requires startLocation. but neither locationId nor locationCoord nor startLocationId nor startLocationCoord has been set"); throw new IllegalArgumentException("Every vehicle requires a start location, but vehicle " + id + " does not have one.");
skills = skillBuilder.build(); skills = skillBuilder.build();
return new VehicleImpl(this); return new VehicleImpl(this);
} }