@Override public void insertJobWithoutTourUpdate(Job job, InsertionData insertionData) { if (insertionData == null || (insertionData instanceof NoInsertionFound)) throw new IllegalStateException("insertionData null. cannot insert job."); if (job == null) throw new IllegalStateException("cannot insert null-job"); if (job instanceof Shipment) { assert insertionData.getInsertionIndeces().length == 2 : "a shipment needs two insertionIndeces. a pickupInsertionIndex and a deliveryInsertionIndex"; try { insertJob( (Shipment) job, insertionData.getInsertionIndeces()[0], insertionData.getInsertionIndeces()[1]); } catch (IndexOutOfBoundsException e) { throw new IllegalStateException("insertionData are invalid for this tour. " + e); } } else if (job instanceof Service) { assert insertionData.getInsertionIndeces().length == 1 : "a service needs one insertionIndeces."; try { insertJob((Service) job, insertionData.getInsertionIndeces()[0]); } catch (IndexOutOfBoundsException e) { throw new IllegalStateException("insertionData are invalid for this tour. " + e); } } else { throw new IllegalStateException("a job must either be a shipment or a service"); } if (insertionData.getSelectedVehicle() != vehicleRoute.getVehicle() && !(vehicleFleetManager instanceof DefaultFleetManager)) { try { vehicleFleetManager.unlock(vehicleRoute.getVehicle()); } catch (IllegalStateException e) { throw new IllegalStateException(); } vehicleFleetManager.lock(insertionData.getSelectedVehicle()); vehicleRoute.setVehicle(insertionData.getSelectedVehicle()); } }