Package de.uni_marburg.mdo_over.model
Class ModelGraphMapping
- java.lang.Object
-
- de.uni_marburg.mdo_over.model.ModelGraphMapping
-
public class ModelGraphMapping extends Object
AModelGraphMapping
represents a mapping of elements between twographs
. 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 asretrieving 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 Summary
Constructors Constructor Description ModelGraphMapping(ModelGraph originGraph, ModelGraph imageGraph)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMapping(ModelGraphElement origin, ModelGraphElement image)
Adds a mapping from origin to image and vice versa.ModelGraphElement
getImage(ModelGraphElement element)
Returns the image ofelement
ifelement
is the origin of a mapping.ModelGraph
getImageGraph()
Get the graph used as image in this mapping.ModelGraphElement
getOrigin(ModelGraphElement element)
Returns the origin ofelement
ifelement
is the image of a mapping.ModelGraph
getOriginGraph()
Get the graph used as origin for this mapping.void
removeMapping(ModelGraphElement origin, ModelGraphElement image)
Removes the mapping between origin and image if this mapping exists.
-
-
-
Constructor Detail
-
ModelGraphMapping
public ModelGraphMapping(ModelGraph originGraph, ModelGraph imageGraph)
-
-
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 substitutedremoveMapping(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 theoriginGraph
which should be mappedimage
- an element of theimageGraph
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 mappingimage
- 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 ofelement
ifelement
is the origin of a mapping.- Parameters:
element
- the element for which an image is looked up- Returns:
- the image of
element
ornull
if the element is not the origin of a mapping
-
getOrigin
public ModelGraphElement getOrigin(ModelGraphElement element)
Returns the origin ofelement
ifelement
is the image of a mapping.- Parameters:
element
- the element for which an origin is looked up- Returns:
- the origin of
element
ornull
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
-
-