Class ModelGraphMapping


  • public class ModelGraphMapping
    extends Object
    A ModelGraphMapping represents a mapping of elements between two graphs. An element of one graph can only be mapped to at most one element of the other graph. While there is made a distinction between the origin and the image graph of such a mapping, actually, the mapping is bi-directional. Retrieving the image of a mapped element of the origin graph as well as retrieving the origin of an element of the image graph is possible.

    Note: While a mapping is forcibly left- and right-unique no assumptions can be made about left- or right-totality.

    Author:
    S. John
    • Constructor Detail

    • Method Detail

      • addMapping

        public void addMapping​(ModelGraphElement origin,
                               ModelGraphElement image)
                        throws IllegalArgumentException
        Adds a mapping from origin to image and vice versa. Both origin and image need to be part of the respective graphs and may not already be mapped. If a mapping between elements needs to be substituted removeMapping(ModelGraphElement, ModelGraphElement) needs to be explicitly called, first.

        Note: Changes to the underlying graphs are not automatically reflected by the mappings. It's the users responsibility to keep the graphs and the mappings aligned.

        Parameters:
        origin - an element of the originGraph which should be mapped
        image - an element of the imageGraph which should be mapped
        Throws:
        IllegalArgumentException - thrown if either origin or image is not part of the respective graph or it is already mapped
      • removeMapping

        public void removeMapping​(ModelGraphElement origin,
                                  ModelGraphElement image)
                           throws IllegalArgumentException
        Removes the mapping between origin and image if this mapping exists.

        Note: Changes to the underlying graphs are not automatically reflected by the mappings. It's the users responsibility to keep the graphs and the mappings aligned.

        Parameters:
        origin - the origin of the mapping
        image - the image the origin is mapped to
        Throws:
        IllegalArgumentException - thrown if origin is not mapped to image
      • getImage

        public ModelGraphElement getImage​(ModelGraphElement element)
        Returns the image of element if element is the origin of a mapping.
        Parameters:
        element - the element for which an image is looked up
        Returns:
        the image of element or null if the element is not the origin of a mapping
      • getOrigin

        public ModelGraphElement getOrigin​(ModelGraphElement element)
        Returns the origin of element if element is the image of a mapping.
        Parameters:
        element - the element for which an origin is looked up
        Returns:
        the origin of element or null if the element is not the image of a mapping
      • getOriginGraph

        public ModelGraph getOriginGraph()
        Get the graph used as origin for this mapping.
        Returns:
        origin graph
      • getImageGraph

        public ModelGraph getImageGraph()
        Get the graph used as image in this mapping.
        Returns:
        image graph