org.eclipse.viatra.transformation.runtime.emf.modelmanipulation

## Interface IEcoreManipulations<RootContainer,ModelObject>

- Type Parameters:
    `RootContainer` - the type of root containers in which model elements may reside (e.g. a `Resource`)
    `ModelObject` - the type representing a model element; can be simply an `EObject` or a surrogate key
  All Known Subinterfaces:
    IModelManipulations
  All Known Implementing Classes:
    AbstractEcoreManipulations, AbstractModelManipulations, IndexHostManipulations, ModelManipulationWithEditingDomain, SimpleModelManipulations

      public interface IEcoreManipulations<RootContainer,ModelObject>

  Interface for commands manipulating some representation of an instance of an Ecore metamodel. `IModelManipulations` is provided as the default case where the instance model is simply an EMF model.

  Note that not all representations may support / preserve ordered collections.

  Since:
    2.1
  No Extend:
    This interface is not intended to be implemented by clients.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default void` | `add(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element)` Adds an existing element to a selected EStructuralFeature.
    `default void` | `add(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element, int index)` Adds an existing element to a selected EStructuralFeature at the specified index.
    `default void` | `addAll(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature reference, java.util.Collection<? extends java.lang.Object> elements)` Adds a collection of existing elements to a selected EStructuralFeature.
    `void` | `addAllTo(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature reference, java.util.Collection<? extends java.lang.Object> elements)` Adds a collection of existing elements to a selected EStructuralFeature.
    `void` | `addTo(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element)` Adds an existing element to a selected EStructuralFeature.
    `void` | `addTo(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element, int index)` Adds an existing element to a selected EStructuralFeature at the specified index.
    `void` | `changeIndex(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int oldIndex, int newIndex)` Changes the position of an existing element in the selected feature of the selected model object.
    `ModelObject` | `create(RootContainer res, org.eclipse.emf.ecore.EClass clazz)` Creates a model object and puts it as the root of the selected root container.
    `ModelObject` | `createChild(ModelObject container, org.eclipse.emf.ecore.EReference reference, org.eclipse.emf.ecore.EClass clazz)` Creates a model object and puts it into the selected reference of a container.
    `void` | `moveAllTo(java.util.Collection<ModelObject> what, ModelObject newContainer, org.eclipse.emf.ecore.EReference reference)` Moves a collection of existing elements into the selected containment reference of the selected model object.
    `void` | `moveTo(ModelObject what, ModelObject newContainer, org.eclipse.emf.ecore.EReference reference)` Moves an existing element into the selected containment reference of the selected model object.
    `void` | `moveTo(ModelObject what, ModelObject newContainer, org.eclipse.emf.ecore.EReference reference, int index)` Moves an existing element into the selected containment reference of the selected model object at the specified index.
    `void` | `moveTo(ModelObject what, RootContainer newContainer)` Moves an existing element into the root of the selected root container.
    `void` | `moveTo(ModelObject what, RootContainer newContainer, int index)` Moves an existing element into the root of the selected root container at the specified index.
    `void` | `remove(ModelObject object)` Removes an object from the model, along with all contained objects, and any incoming or outgoing references.
    `void` | `remove(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature)` Removes all elements from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).
    `void` | `remove(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, int index)` Removes the element at the specified index from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).
    `void` | `remove(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object element)` Removes an element from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).
    `void` | `set(ModelObject container, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.Object value)` Sets a 'single'-valued EStructuralFeature of a given container model element to the given value.

- - ### Method Detail

    - #### create

          ModelObject create(RootContainer res,
                             org.eclipse.emf.ecore.EClass clazz)
                      throws ModelManipulationException

      Creates a model object and puts it as the root of the selected root container.
      Throws:
        `ModelManipulationException`

    - #### createChild

          ModelObject createChild(ModelObject container,
                                  org.eclipse.emf.ecore.EReference reference,
                                  org.eclipse.emf.ecore.EClass clazz)
                           throws ModelManipulationException

      Creates a model object and puts it into the selected reference of a container. The container reference must be a containment reference.
      Throws:
        `ModelManipulationException`

    - #### add

          default void add(ModelObject container,
                           org.eclipse.emf.ecore.EStructuralFeature feature,
                           java.lang.Object element)
                    throws ModelManipulationException

      Adds an existing element to a selected EStructuralFeature. If the feature is an EReference, it must not be a containment reference.

      Same as `addTo(Object, EStructuralFeature, Object)`

      Throws:
        `ModelManipulationException`

    - #### add

          default void add(ModelObject container,
                           org.eclipse.emf.ecore.EStructuralFeature feature,
                           java.lang.Object element,
                           int index)
                    throws ModelManipulationException

      Adds an existing element to a selected EStructuralFeature at the specified index. If the feature is an EReference, it must not be a containment reference.
      Throws:
        `ModelManipulationException`
      Since:
        1.2

        Same as `addTo(Object, EStructuralFeature, Object, int)`

    - #### addAll

          default void addAll(ModelObject container,
                              org.eclipse.emf.ecore.EStructuralFeature reference,
                              java.util.Collection<? extends java.lang.Object> elements)
                       throws ModelManipulationException

      Adds a collection of existing elements to a selected EStructuralFeature. If the feature is an EReference, it must not be a containment reference.

      Same as `addAllTo(Object, EStructuralFeature, Collection)`

      Throws:
        `ModelManipulationException`

    - #### addTo

          void addTo(ModelObject container,
                     org.eclipse.emf.ecore.EStructuralFeature feature,
                     java.lang.Object element)
              throws ModelManipulationException

      Adds an existing element to a selected EStructuralFeature. If the feature is an EReference, it must not be a containment reference.
      Throws:
        `ModelManipulationException`

    - #### addTo

          void addTo(ModelObject container,
                     org.eclipse.emf.ecore.EStructuralFeature feature,
                     java.lang.Object element,
                     int index)
              throws ModelManipulationException

      Adds an existing element to a selected EStructuralFeature at the specified index. If the feature is an EReference, it must not be a containment reference.
      Throws:
        `ModelManipulationException`
      Since:
        1.2

    - #### addAllTo

          void addAllTo(ModelObject container,
                        org.eclipse.emf.ecore.EStructuralFeature reference,
                        java.util.Collection<? extends java.lang.Object> elements)
                 throws ModelManipulationException

      Adds a collection of existing elements to a selected EStructuralFeature. If the feature is an EReference, it must not be a containment reference.
      Throws:
        `ModelManipulationException`

    - #### set

          void set(ModelObject container,
                   org.eclipse.emf.ecore.EStructuralFeature feature,
                   java.lang.Object value)
            throws ModelManipulationException

      Sets a 'single'-valued EStructuralFeature of a given container model element to the given value.

      The previous value of the feature, if any, is removed. If the provided new value is null, then the invocation acts as 'unset', and no new value is stored.

      Parameters:
        `value` - the new value to be set, or null

        TODO restrict to non-containment?

      Throws:
        `ModelManipulationException`

    - #### remove

          void remove(ModelObject container,
                      org.eclipse.emf.ecore.EStructuralFeature feature,
                      java.lang.Object element)
               throws ModelManipulationException

      Removes an element from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).
      Throws:
        `ModelManipulationException`

    - #### remove

          void remove(ModelObject container,
                      org.eclipse.emf.ecore.EStructuralFeature feature,
                      int index)
               throws ModelManipulationException

      Removes the element at the specified index from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).
      Throws:
        `ModelManipulationException`
      Since:
        1.2

    - #### remove

          void remove(ModelObject container,
                      org.eclipse.emf.ecore.EStructuralFeature feature)
               throws ModelManipulationException

      Removes all elements from the 'many'-valued reference; if the reference is a containment reference, the element is removed from the model as well (it is assumed that no dangling cross-references point to it).
      Throws:
        `ModelManipulationException`

    - #### remove

          void remove(ModelObject object)
               throws ModelManipulationException

      Removes an object from the model, along with all contained objects, and any incoming or outgoing references.
      Throws:
        `ModelManipulationException`

    - #### moveTo

          void moveTo(ModelObject what,
                      RootContainer newContainer)
               throws ModelManipulationException

      Moves an existing element into the root of the selected root container.
      Throws:
        `ModelManipulationException`

    - #### moveTo

          void moveTo(ModelObject what,
                      RootContainer newContainer,
                      int index)
               throws ModelManipulationException

      Moves an existing element into the root of the selected root container at the specified index.
      Throws:
        `ModelManipulationException`
      Since:
        1.2

    - #### moveTo

          void moveTo(ModelObject what,
                      ModelObject newContainer,
                      org.eclipse.emf.ecore.EReference reference)
               throws ModelManipulationException

      Moves an existing element into the selected containment reference of the selected model object.
      Throws:
        `ModelManipulationException`

    - #### moveTo

          void moveTo(ModelObject what,
                      ModelObject newContainer,
                      org.eclipse.emf.ecore.EReference reference,
                      int index)
               throws ModelManipulationException

      Moves an existing element into the selected containment reference of the selected model object at the specified index.
      Throws:
        `ModelManipulationException`
      Since:
        1.2

    - #### moveAllTo

          void moveAllTo(java.util.Collection<ModelObject> what,
                         ModelObject newContainer,
                         org.eclipse.emf.ecore.EReference reference)
                  throws ModelManipulationException

      Moves a collection of existing elements into the selected containment reference of the selected model object.
      Throws:
        `ModelManipulationException`

    - #### changeIndex

          void changeIndex(ModelObject container,
                           org.eclipse.emf.ecore.EStructuralFeature feature,
                           int oldIndex,
                           int newIndex)
                    throws ModelManipulationException

      Changes the position of an existing element in the selected feature of the selected model object.
      Throws:
        `ModelManipulationException`
      Since:
        1.2