Source:
<code>public CommandResult<CanvasViolation> move(final Element[] elements, final Point2D[] locations) { if (elements.length != locations.length) { throw new IllegalArgumentException("The length for the elements to move " + "does not match the locations provided."); } final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> builder = new CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation>() .forward(); int i = 0; for (final Element element : elements) { <START> builder.addCommand(createMoveCommand(element, locations[i++])); <END> ShapeView shapeView = canvasHandler.getCanvas().getShape(element.getUUID()).getShapeView(); if (shapeView instanceof WiresShape) { ShapeControlUtils.getChildConnectorWithinShape((WiresShape) shapeView).values() .stream() .forEach(wiresConnector -> { Optional.ofNullable(canvasHandler.getGraphIndex().getEdge(WiresUtils.getShapeUUID(wiresConnector.getGroup()))) .ifPresent(edge -> { final Point2DArray controlPoints = wiresConnector.getControlPoints(); builder.addCommands(moveControlPointsCommands(edge, controlPoints)); }); }); } } final Command<AbstractCanvasHandler, CanvasViolation> command = builder.build(); CommandResult<CanvasViolation> result = getCommandManager().allow(canvasHandler, command); if (!CommandUtils.isError(result)) { result = getCommandManager().execute(canvasHandler, command); if (!CommandUtils.isError(result)) { List<String> uuids = Arrays.stream(elements).map(Element::getUUID).collect(Collectors.toList()); shapeLocationsChangedEvent.fire(new ShapeLocationsChangedEvent(uuids, canvasHandler)); } } return result; }</code><technical_language>In opinion, this approach of for loop lead making mistakes. I classic for loop. do think</technical_language>

Target:
public CommandResult<CanvasViolation> move(final Element[] elements, final Point2D[] locations) { if (elements.length != locations.length) { throw new IllegalArgumentException("The length for the elements to move " + "does not match the locations provided."); } final CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation> builder = new CompositeCommand.Builder<AbstractCanvasHandler, CanvasViolation>() .forward(); for (int i = 0; i < elements.length; i++) { final Element element = elements[i]; builder.addCommand(createMoveCommand(element, locations[i])); ShapeView shapeView = canvasHandler.getCanvas().getShape(element.getUUID()).getShapeView(); if (shapeView instanceof WiresShape) { ShapeControlUtils.getChildConnectorWithinShape((WiresShape) shapeView).values() .stream() .forEach(wiresConnector -> { Optional.ofNullable(canvasHandler.getGraphIndex().getEdge(WiresUtils.getShapeUUID(wiresConnector.getGroup()))) .ifPresent(edge -> { final Point2DArray controlPoints = wiresConnector.getControlPoints(); builder.addCommands(moveControlPointsCommands(edge, controlPoints)); }); }); } } final Command<AbstractCanvasHandler, CanvasViolation> command = builder.build(); CommandResult<CanvasViolation> result = getCommandManager().allow(canvasHandler, command); if (!CommandUtils.isError(result)) { result = getCommandManager().execute(canvasHandler, command); if (!CommandUtils.isError(result)) { List<String> uuids = Arrays.stream(elements).map(Element::getUUID).collect(Collectors.toList()); shapeLocationsChangedEvent.fire(new ShapeLocationsChangedEvent(uuids, canvasHandler)); } } return result; }