for (int i = 0; i < array.size(); i++) {
final JsonObject chartElement = array.get(i).getAsJsonObject();
JsonCommand chartCommand = JsonCommand.fromExistingCommand(command, chartElement);
if (chartCommand.parameterExists(idParamName)) {
final Long chartId = chartCommand.longValueOfParameterNamed(idParamName);
final InterestRateChart chart = this.findChart(chartId);
if (chart == null) {
baseDataValidator.parameter(idParamName).value(chartId).failWithCode("no.chart.associated.with.id");
} else if (chartCommand.parameterExists(deleteParamName)) {
if (this.removeChart(chart)) {
deletedCharts.put(idParamName, chartId);
}
} else {
chart.update(chartCommand, chartsChanges, baseDataValidator, this.setOfCharts(), this.currency().getCode());
}
} else {
// assemble chart
final InterestRateChart newChart = this.chartAssembler.assembleFrom(chartElement, this.currency().getCode());
this.addChart(newChart);
}
}
}
}