de.cau.cs.kieler.ktm.extensions

## Class TransformationMapping

- java.lang.Object
- - de.cau.cs.kieler.ktm.extensions.TransformationMapping

-     public class TransformationMapping
      extends java.lang.Object

  Extension for creating mappings during transformation.
  Author:
    als

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TransformationMapping()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.eclipse.xtext.xbase.lib.Pair<com.google.common.collect.ImmutableSet<org.eclipse.emf.ecore.EObject>,com.google.common.collect.ImmutableSet<org.eclipse.emf.ecore.EObject>>` | `checkMappingCompleteness(org.eclipse.emf.ecore.EObject sourceModel, org.eclipse.emf.ecore.EObject targetModel)` Checks if mapping is complete All objects in sourceModel are compared with parents and all targetModel objects are compared to children, both includes given source/target-model objects.
    `void` | `clearMapping()` Drops all current mapping information
    `com.google.common.collect.ImmutableMultimap<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject>` | `extractMappingData()` This will extract mapping data as an immutable copy and clears local mapping afterwards
    `boolean` | `mapChild(org.eclipse.emf.ecore.EObject parent, org.eclipse.emf.ecore.EObject child)` Maps given child as result of this transformation for given parent.
    `boolean` | `mapChildren(org.eclipse.emf.ecore.EObject parent, java.util.List<org.eclipse.emf.ecore.EObject> children)` Maps given children as results of this transformation for given parent.
    `boolean` | `mapParent(org.eclipse.emf.ecore.EObject child, org.eclipse.emf.ecore.EObject parent)` Maps given parent as source of given child in this transformation.
    `boolean` | `mapParents(org.eclipse.emf.ecore.EObject child, java.util.List<org.eclipse.emf.ecore.EObject> parents)` Maps given parents as source of given child in this transformation.
    `java.util.List<org.eclipse.emf.ecore.EObject>` | `mappedChildren(org.eclipse.emf.ecore.EObject parent)` Returns all Children mapped to given parent
    `<T extends org.eclipse.emf.ecore.EObject> T` | `mappedCopy(T original)` Creates direct mapping between two identical models.
    `java.util.List<org.eclipse.emf.ecore.EObject>` | `mappedParents(org.eclipse.emf.ecore.EObject child)` Returns all Parents mapped to given child
    `boolean` | `unmap(org.eclipse.emf.ecore.EObject first, org.eclipse.emf.ecore.EObject second)` Removes mapping between given objects.
    `boolean` | `unmapAll(org.eclipse.emf.ecore.EObject obj)` Removes all mappings for given objects.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TransformationMapping

          public TransformationMapping()

  - ### Method Detail

    - #### checkMappingCompleteness

          public org.eclipse.xtext.xbase.lib.Pair<com.google.common.collect.ImmutableSet<org.eclipse.emf.ecore.EObject>,com.google.common.collect.ImmutableSet<org.eclipse.emf.ecore.EObject>> checkMappingCompleteness(org.eclipse.emf.ecore.EObject sourceModel,
                                                                                                                                                                                                               org.eclipse.emf.ecore.EObject targetModel)

      Checks if mapping is complete

      All objects in sourceModel are compared with parents and all targetModel objects are compared to children, both includes given source/target-model objects.

      Returns Pair of two sets where were key-element is symmetric difference between source model objects and all parents and value-element is symmetric difference between target and children. All elements are mapped correctly if both sets are empty.

      Returns:
        Pair of two Sets with symmetric differences.
      Throws:
        `java.lang.NullPointerException` - if sourceModel or targetMode is null.

    - #### clearMapping

          public void clearMapping()

      Drops all current mapping information

    - #### extractMappingData

          public com.google.common.collect.ImmutableMultimap<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject> extractMappingData()

      This will extract mapping data as an immutable copy and clears local mapping afterwards
      Returns:
        mapping

    - #### mapChild

          public boolean mapChild(org.eclipse.emf.ecore.EObject parent,
                         org.eclipse.emf.ecore.EObject child)

      Maps given child as result of this transformation for given parent.
      Returns:
        true if the mapping changed.
      Throws:
        `de.cau.cs.kieler.ktm.exceptions.MappingException` - when child parent relations were mixed (i.e. when one object is will be mapped as parent when it is already mapped as child).
        `java.lang.NullPointerException` - if parent or child is null.

    - #### mapChildren

          public boolean mapChildren(org.eclipse.emf.ecore.EObject parent,
                            java.util.List<org.eclipse.emf.ecore.EObject> children)

      Maps given children as results of this transformation for given parent.
      Returns:
        true if the mapping changed.
      Throws:
        `de.cau.cs.kieler.ktm.exceptions.MappingException` - when child parent relations were mixed (i.e. when one object is will be mapped as parent when it is already mapped as child).
        `java.lang.NullPointerException` - if parent or children list is null.
        `java.lang.IllegalArgumentException` - if children list contains null element.

    - #### mapParent

          public boolean mapParent(org.eclipse.emf.ecore.EObject child,
                          org.eclipse.emf.ecore.EObject parent)

      Maps given parent as source of given child in this transformation.
      Returns:
        true if the mapping changed.
      Throws:
        `de.cau.cs.kieler.ktm.exceptions.MappingException` - when child parent relations were mixed (i.e. when one object is will be mapped as parent when it is already mapped as child).
        `java.lang.NullPointerException` - if parent or child is null.

    - #### mapParents

          public boolean mapParents(org.eclipse.emf.ecore.EObject child,
                           java.util.List<org.eclipse.emf.ecore.EObject> parents)

      Maps given parents as source of given child in this transformation.
      Returns:
        true if the mapping changed.
      Throws:
        `de.cau.cs.kieler.ktm.exceptions.MappingException` - when child parent relations were mixed (i.e. when one object is will be mapped as parent when it is already mapped as child).
        `java.lang.NullPointerException` - if parents or child is null.
        `java.lang.IllegalArgumentException` - if children list contains null element.

    - #### mappedChildren

          public java.util.List<org.eclipse.emf.ecore.EObject> mappedChildren(org.eclipse.emf.ecore.EObject parent)

      Returns all Children mapped to given parent
      Returns:
        List of children for parent

    - #### mappedCopy

          public <T extends org.eclipse.emf.ecore.EObject> T mappedCopy(T original)

      Creates direct mapping between two identical models.

      Use for transformations based on copies.

      Mapping will include given root elements.

      Parameters:
        `original` - model to copy
      Returns:
        copy

    - #### mappedParents

          public java.util.List<org.eclipse.emf.ecore.EObject> mappedParents(org.eclipse.emf.ecore.EObject child)

      Returns all Parents mapped to given child
      Returns:
        List of parents for child

    - #### unmap

          public boolean unmap(org.eclipse.emf.ecore.EObject first,
                      org.eclipse.emf.ecore.EObject second)

      Removes mapping between given objects.

      Parent child order is arbitrary.

      Parameters:
        `first` - - parent or child object depending on chosen order
        `second` - - parent or child object depending on chosen order
      Returns:
        true if the mapping changed

    - #### unmapAll

          public boolean unmapAll(org.eclipse.emf.ecore.EObject obj)

      Removes all mappings for given objects.

      Object can be parent or child

      Returns:
        true if the mapping changed