class VehicleService {

    public void changeCapacity(long vehicleId, int capacity) {
        Vehicle vehicle = vehicleRepository.find(vehicleId).orElseThrow(() -> new IllegalArgumentException(
                "Can't remove Vehicle{id=" + vehicleId + "} because it doesn't exist"));
        Vehicle updatedVehicle = VehicleFactory.createVehicle(vehicle.id(), vehicle.name(), capacity);
        vehicleRepository.update(updatedVehicle);
        optimizer.changeCapacity(updatedVehicle);
    }

    @Autowired public  VehicleService(RouteOptimizer optimizer, VehicleRepository vehicleRepository);

}