From 427b9a081ee739a2ad0063f54f6dae3284218862 Mon Sep 17 00:00:00 2001 From: oblonski <4sschroeder@gmail.com> Date: Tue, 22 Jul 2014 16:09:44 +0200 Subject: [PATCH] modified core.algorithm.state.StateManager such that it throws NullPointerException if state does not exist but should --- .../java/jsprit/core/algorithm/state/StateManager.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateManager.java b/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateManager.java index 7ea2fce1..ba4a797e 100644 --- a/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateManager.java +++ b/jsprit-core/src/main/java/jsprit/core/algorithm/state/StateManager.java @@ -271,7 +271,7 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart catch (ClassCastException e){ throw getClassCastException(e,stateId,type.toString(),activity_states[act.getIndex()][stateId.getIndex()].getClass().toString()); } - if(state == null) return getDefaultTypedActivityState(act, stateId, type); + if(state == null) throw new NullPointerException("state " + stateId.toString() + " of activity " + act + " is missing."); return state; } @@ -293,7 +293,7 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart Object state_class = vehicle_dependent_activity_states[act.getIndex()][vehicle.getVehicleTypeIdentifier().getIndex()][stateId.getIndex()]; throw getClassCastException(e,stateId,type.toString(),state_class.getClass().toString()); } - if(state == null) return getDefaultTypedActivityState(act, stateId, type); + if(state == null) throw new NullPointerException("state " + stateId.toString() + " of activity " + act + " for vehicle " + vehicle.getId() + " is missing."); return state; } @@ -337,7 +337,7 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart catch (ClassCastException e){ throw getClassCastException(e,stateId,type.toString(),route_states[route.getActivities().get(0).getIndex()][stateId.getIndex()].getClass().toString()); } - if(state==null) return getDefaultTypedRouteState(stateId,type); + if(state==null) throw new NullPointerException("state " + stateId.toString() + " of route " + route + " is missing."); return state; } @@ -354,7 +354,7 @@ public class StateManager implements RouteAndActivityStateGetter, IterationStart catch( ClassCastException e){ throw getClassCastException(e, stateId, type.toString(), vehicle_dependent_route_states[route.getActivities().get(0).getIndex()][vehicle.getVehicleTypeIdentifier().getIndex()][stateId.getIndex()].getClass().toString()); } - if(state==null) return getDefaultTypedRouteState(stateId,type); + if(state==null) throw new NullPointerException("state " + stateId.toString() + " of route " + route + " for vehicle " + vehicle.getId() + " is missing."); return state; }