class CaseManagementSetChildNodeCanvasCommand extends org.kie.workbench.common.stunner.core.client.canvas.command.SetCanvasChildrenCommand {

    @Override
    public CommandResult<CanvasViolation> undo(final AbstractCanvasHandler context) {
        if (!(originalParent.isPresent() && originalIndex.isPresent())) {
            return new RemoveCanvasChildrenCommand(getParent(),
                                                   getCandidate()).execute(context);
        } else {
            context.addChild(originalParent.get(),
                             getCandidate(),
                             originalIndex.getAsInt());
            context.updateElementProperties(getCandidate(),
                                            MutationContext.STATIC);
        }
        return buildResult();
    }

    @SuppressWarnings("unchecked") public  CaseManagementSetChildNodeCanvasCommand(final Node<View<?>, Edge> parent,
                                                   final Node<View<?>, Edge> child,
                                                   final OptionalInt index,
                                                   final Optional<Node<View<?>, Edge>> originalParent,
                                                   final OptionalInt originalIndex);

}