class CaseManagementSetChildNodeGraphCommand extends AbstractGraphCommand {

    @Override
    @SuppressWarnings("unchecked")
    public CommandResult<RuleViolation> undo(final GraphCommandExecutionContext context) {
        //Remove existing relationship
        getEdgeForTarget(in, child, sequencePredicate())
                .ifPresent((e) -> removeRelationship(e,
                                                     in.get(),
                                                     child,
                                                     context));
        getEdgeForSource(out, child, sequencePredicate())
                .ifPresent((e) -> removeRelationship(e,
                                                     child,
                                                     out.get(),
                                                     context));

        getEdgeForTarget(Optional.of(parent), child, childPredicate())
                .ifPresent((e) -> removeRelationship(e,
                                                     parent,
                                                     child,
                                                     context));
        edge.ifPresent(e -> addRelationship(in.get(),
                                            out.get(),
                                            OptionalInt.empty(),
                                            context,
                                            sequenceFlowSupplier()));

        //Add new relationship
        if (originalIn.isPresent() && originalOut.isPresent()) {
            getEdgeForTarget(originalIn, originalOut.get(), sequencePredicate())
                    .ifPresent((e) -> removeRelationship(e,
                                                         originalIn.get(),
                                                         originalOut.get(),
                                                         context));
        }

        originalOut.ifPresent((p) -> addRelationship(child,
                                                     originalOut.get(),
                                                     OptionalInt.empty(),
                                                     context,
                                                     sequenceFlowSupplier()));

        originalIn.ifPresent((p) -> addRelationship(originalIn.get(),
                                                    child,
                                                    OptionalInt.empty(),
                                                    context,
                                                    sequenceFlowSupplier()));

        originalParent.ifPresent((p) -> addRelationship(originalParent.get(),
                                                        child,
                                                        originalIndex,
                                                        context,
                                                        Child::new));

        undoResizeNodes();

        return GraphCommandResultBuilder.SUCCESS;
    }

    public  CaseManagementSetChildNodeGraphCommand(final Node<View<?>, Edge> parent,
                                                  final Node<View<?>, Edge> child,
                                                  final OptionalInt index,
                                                  final Optional<Node<View<?>, Edge>> originalParent,
                                                  final OptionalInt originalIndex);

}