private static IResourceAggregate instructionsToResources(
IJobUpdateInstructions instructions,
final boolean isProd) {
// Calculate initial state consumption.
IResourceAggregate initial = ResourceAggregates.EMPTY;
for (IInstanceTaskConfig group : instructions.getInitialState()) {
ITaskConfig task = group.getTask();
if (isProd == task.isProduction()) {
for (IRange range : group.getInstances()) {
initial = add(initial, ResourceAggregates.scale(
fromTasks(ImmutableSet.of(task)),
instanceCountFromRange(range)));
}
}
}
// Calculate desired state consumption.
IResourceAggregate desired = Optional.fromNullable(instructions.getDesiredState())
.transform(new Function<IInstanceTaskConfig, IResourceAggregate>() {
@Override
public IResourceAggregate apply(IInstanceTaskConfig input) {
return isProd == input.getTask().isProduction()
? ResourceAggregates.scale(