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
parent b78a144011
commit 76aa6938db
No known key found for this signature in database
GPG key ID: 179DE487285680D1

View file

@ -145,7 +145,7 @@ public class VehicleImpl extends AbstractVehicle {
* @throws IllegalArgumentException if type is null
*/
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;
return this;
}
@ -213,7 +213,7 @@ public class VehicleImpl extends AbstractVehicle {
*/
public Builder setEarliestStart(double earliest_startTime) {
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;
return this;
}
@ -226,7 +226,7 @@ public class VehicleImpl extends AbstractVehicle {
*/
public Builder setLatestArrival(double latest_arrTime) {
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;
return this;
}
@ -254,17 +254,17 @@ public class VehicleImpl extends AbstractVehicle {
*/
public VehicleImpl build() {
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.getId().equals(endLocation.getId()) && !returnToDepot)
throw new IllegalArgumentException("this must not be. you specified both endLocationId and open-routes. this is contradictory. <br>" +
"if you set endLocation, returnToDepot must be true. if returnToDepot is false, endLocationCoord must not be specified.");
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. " +
"Either specify end location and return to depot or leave end location unspecified.");
}
if (startLocation != null && endLocation == null) {
endLocation = startLocation;
}
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();
return new VehicleImpl(this);
}