Class HenshinRuleAdapter
- java.lang.Object
-
- de.uni_marburg.mdo_over.graphtools.emf.HenshinRuleAdapter
-
- Direct Known Subclasses:
GraphRuleAdapter
,MappingRuleAdapter
public abstract class HenshinRuleAdapter extends Object
Adapter betweenmodel graphs
,model graph mappings
andHenshin rules
. Can be used to create and apply rules based on model graphs and their mappings.Note: The rule reflecting a mapping is created during initialization. Later changes to the underlying model graph or model graph mapping are not reflected.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.eclipse.emf.henshin.interpreter.Match
match
protected org.eclipse.emf.henshin.interpreter.Match
resultMatch
protected org.eclipse.emf.henshin.model.Rule
rule
-
Constructor Summary
Constructors Modifier Constructor Description protected
HenshinRuleAdapter(org.eclipse.emf.henshin.interpreter.Engine engine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addModelEdgeToRule(ModelEdge edge, org.eclipse.emf.henshin.model.compact.CRule cRule, org.eclipse.emf.henshin.model.Action action)
protected org.eclipse.emf.henshin.model.compact.CNode
addModelNodeToRuleIfAbsent(ModelNode node, Set<org.eclipse.emf.ecore.EAttribute> ignoredAttributes, org.eclipse.emf.henshin.model.compact.CRule cRule, org.eclipse.emf.henshin.model.Action action)
Add a rule node to the given rule representing the object referenced by the given node.org.eclipse.emf.ecore.EObject
applyRule(org.eclipse.emf.ecore.EObject emfModel, org.eclipse.emf.henshin.interpreter.Match partialMatch)
Applies the rule represented by this adapter to the givenemfModel
.org.eclipse.emf.henshin.interpreter.Match
findMatch(org.eclipse.emf.ecore.EObject emfModel)
Returns aMatch
in the givenemfModel
for the rule represented by this adapter.org.eclipse.emf.henshin.interpreter.Match
getLastMatch()
org.eclipse.emf.henshin.interpreter.Match
getResultMatch()
Returns the result match of the lastapplication
of the rule of this adapter.org.eclipse.emf.henshin.model.Rule
getRule()
-
-
-
Method Detail
-
getRule
public org.eclipse.emf.henshin.model.Rule getRule()
-
applyRule
public org.eclipse.emf.ecore.EObject applyRule(org.eclipse.emf.ecore.EObject emfModel, org.eclipse.emf.henshin.interpreter.Match partialMatch)
Applies the rule represented by this adapter to the givenemfModel
. A partial match can be specified to enforce rule nodes to be mapped to specific objects of the model. Returns the root of the resulting EMF model ornull
if the rule could not be applied.- Parameters:
emfModel
- model to apply the rule topartialMatch
- a (partial) mapping of rule nodes to objects of the given model- Returns:
- root of the resulting EMF model or
null
if the rule could not be applied
-
findMatch
public org.eclipse.emf.henshin.interpreter.Match findMatch(org.eclipse.emf.ecore.EObject emfModel)
Returns aMatch
in the givenemfModel
for the rule represented by this adapter. Returnsnull
if no such match exists.- Parameters:
emfModel
- model to find a match in- Returns:
- a match for the rule or
null
if no match exists
-
getLastMatch
public org.eclipse.emf.henshin.interpreter.Match getLastMatch()
- Returns:
- the last match for the rule or
null
if no last match exists
-
getResultMatch
public org.eclipse.emf.henshin.interpreter.Match getResultMatch()
Returns the result match of the lastapplication
of the rule of this adapter.- Returns:
- the result match of the last rule application or null if the last rule application was not successful
-
addModelEdgeToRule
protected void addModelEdgeToRule(ModelEdge edge, org.eclipse.emf.henshin.model.compact.CRule cRule, org.eclipse.emf.henshin.model.Action action) throws MalformedGraphException, IllegalArgumentException
-
addModelNodeToRuleIfAbsent
protected org.eclipse.emf.henshin.model.compact.CNode addModelNodeToRuleIfAbsent(ModelNode node, Set<org.eclipse.emf.ecore.EAttribute> ignoredAttributes, org.eclipse.emf.henshin.model.compact.CRule cRule, org.eclipse.emf.henshin.model.Action action)
Add a rule node to the given rule representing the object referenced by the given node. A set of ignored attributes can be specified which will not be considered in this rule for the given node.- Parameters:
node
-ModelNode
that needs to be represented in the ruleignoredAttributes
- attributes not considered for the given nodecRule
- rule to extendaction
- action type of the added rule node- Returns:
- the added rule node
-
-