From ae1d4004a511b30a6e4e20e4db5916fcb2069f48 Mon Sep 17 00:00:00 2001 From: oblonski Date: Mon, 11 Dec 2017 13:29:44 +0100 Subject: [PATCH] throw exception if vehicle id is null --- .../graphhopper/jsprit/core/problem/vehicle/VehicleImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/vehicle/VehicleImpl.java b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/vehicle/VehicleImpl.java index 809f2adf..3686d703 100644 --- a/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/vehicle/VehicleImpl.java +++ b/jsprit-core/src/main/java/com/graphhopper/jsprit/core/problem/vehicle/VehicleImpl.java @@ -135,6 +135,7 @@ public class VehicleImpl extends AbstractVehicle { private Builder(String id) { super(); this.id = id; + if (id == null) throw new IllegalArgumentException("Vehicle id must not be null."); } /** @@ -196,6 +197,8 @@ public class VehicleImpl extends AbstractVehicle { * @return start location */ public Builder setStartLocation(Location startLocation) { + if (startLocation == null) + throw new IllegalArgumentException("Start location of vehicle " + id + " must not be null."); this.startLocation = startLocation; return this; } @@ -232,6 +235,7 @@ public class VehicleImpl extends AbstractVehicle { } public Builder addSkill(String skill) { + if (skill == null) throw new IllegalArgumentException("Skill of vehicle " + id + " must not be null"); skillBuilder.addSkill(skill); return this; }