From 4b8876b1c6749682d623fce4693f307c803f2016 Mon Sep 17 00:00:00 2001 From: Stefan Schroeder <4sschroeder@gmail.com> Date: Mon, 2 Sep 2013 17:20:49 +0200 Subject: [PATCH] add precondition to service: capacity-demand must be greater than or equal to zero --- jsprit-core/src/main/java/basics/Service.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsprit-core/src/main/java/basics/Service.java b/jsprit-core/src/main/java/basics/Service.java index b35481b6..17c52371 100644 --- a/jsprit-core/src/main/java/basics/Service.java +++ b/jsprit-core/src/main/java/basics/Service.java @@ -41,7 +41,7 @@ public class Service implements Job { protected int demand; Builder(String id, int size) { - super(); + if(size < 0) throw new IllegalArgumentException("size must be greater than or equal to zero"); this.id = id; this.demand = size; } @@ -62,6 +62,7 @@ public class Service implements Job { } public Builder setServiceTime(double serviceTime){ + if(serviceTime < 0) throw new IllegalArgumentException("serviceTime must be greate than or equal to zero"); this.serviceTime = serviceTime; return this; }