Source:
public TaskResult run() { Config params = request.getConfig(); Config doConfig = request.getConfig().getNested("_do"); boolean parallel = params.get("_parallel", boolean.class, false); Config rangeConfig = params.parseNested("_command"); long from = rangeConfig.get("from", long.class); long until = rangeConfig.get("until", long.class); Optional<Long> stepConfig = request.getConfig().getOptional("step", Long.class); Optional<Long> countConfig = request.getConfig().getOptional("count", Long.class); if (stepConfig.isPresent() && countConfig.isPresent()) { throw new ConfigException("Setting both step and count options to for_range is invalid"); } if (!stepConfig.isPresent() && !countConfig.isPresent()) { throw new ConfigException("step or count option is required for for_range"); } long step = stepConfig.or(() -> (until - from + (countConfig.get() - 1)) / countConfig.get()); int count = 0; Config generated = doConfig.getFactory().create(); for (long pos = from; pos < until; pos += step) { long rangeFrom = pos; long rangeUntil = Math.min(pos + step, until); Config exportParams = params.getFactory().create(); exportParams.getNestedOrSetEmpty("range") .set("from", rangeFrom) .set("until", rangeUntil); Config subtask = params.getFactory().create(); subtask.setAll(doConfig); subtask.getNestedOrSetEmpty("_export").setAll(exportParams); generated.set( buildTaskName(rangeFrom, rangeUntil), subtask); count++; } enforceTaskCountLimit(count); if (parallel) { generated.set("_parallel", parallel); } return TaskResult.defaultBuilder(request) .subtaskConfig(generated) .build(); }

Target:
public TaskResult run() { Config params = request.getConfig(); Config doConfig = request.getConfig().getNested("_do"); boolean parallel = params.get("_parallel", boolean.class, false); Config rangeConfig = params.parseNested("_command"); long from = rangeConfig.get("from", long.class); long to = rangeConfig.get("to", long.class); Optional<Long> stepConfig = rangeConfig.getOptional("step", Long.class); Optional<Long> slicesConfig = rangeConfig.getOptional("slices", Long.class); if (stepConfig.isPresent() && slicesConfig.isPresent()) { throw new ConfigException("Setting both step and slices options to for_range is invalid"); } if (!stepConfig.isPresent() && !slicesConfig.isPresent()) { throw new ConfigException("step or slices option is required for for_range"); } if (stepConfig.isPresent() && stepConfig.get() <= 0) { throw new ConfigException("step option must be same or greater than 1 but got " + stepConfig.get()); } if (slicesConfig.isPresent() && slicesConfig.get() <= 0) { throw new ConfigException("slices option must be same or greater than 1 but got " + slicesConfig.get()); } long step = stepConfig.or(() -> (to - from + (slicesConfig.get() - 1)) / slicesConfig.get()); assert step > 0; int index = 0; Config generated = doConfig.getFactory().create(); for (long pos = from; pos < to; pos += step) { long rangeFrom = pos; long rangeTo = Math.min(pos + step, to); Config exportParams = params.getFactory().create(); exportParams.getNestedOrSetEmpty("range") .set("from", rangeFrom) .set("to", rangeTo) .set("index", index); Config subtask = params.getFactory().create(); subtask.setAll(doConfig); subtask.getNestedOrSetEmpty("_export").setAll(exportParams); generated.set( buildTaskName(rangeFrom, rangeTo), subtask); index++; } enforceTaskCountLimit(index); if (parallel) { generated.set("_parallel", parallel); } return TaskResult.defaultBuilder(request) .subtaskConfig(generated) .build(); }