class ChangeVehicleCapacity implements ProblemFactChange<VehicleRoutingSolution> {

    @Override
    public void doChange(ScoreDirector<VehicleRoutingSolution> scoreDirector) {
        PlanningVehicle workingVehicle = scoreDirector.lookUpWorkingObject(vehicle);
        if (workingVehicle == null) {
            throw new IllegalStateException("Can't look up a working copy of " + vehicle);
        }

        // No need to clone the workingVehicle because it is a planning entity, so it is already planning-cloned.
        // To learn more about problem fact changes, see:
        // https://docs.jboss.org/optaplanner/release/latest/optaplanner-docs/html_single/#problemFactChangeExample

        scoreDirector.beforeProblemPropertyChanged(workingVehicle);
        workingVehicle.setCapacity(vehicle.getCapacity());
        scoreDirector.afterProblemPropertyChanged(workingVehicle);

        scoreDirector.triggerVariableListeners();
    }

    public  ChangeVehicleCapacity(PlanningVehicle vehicle);

}