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 mappingsandHenshin 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.Matchmatchprotected org.eclipse.emf.henshin.interpreter.MatchresultMatchprotected org.eclipse.emf.henshin.model.Rulerule
-
Constructor Summary
Constructors Modifier Constructor Description protectedHenshinRuleAdapter(org.eclipse.emf.henshin.interpreter.Engine engine)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddModelEdgeToRule(ModelEdge edge, org.eclipse.emf.henshin.model.compact.CRule cRule, org.eclipse.emf.henshin.model.Action action)protected org.eclipse.emf.henshin.model.compact.CNodeaddModelNodeToRuleIfAbsent(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.EObjectapplyRule(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.MatchfindMatch(org.eclipse.emf.ecore.EObject emfModel)Returns aMatchin the givenemfModelfor the rule represented by this adapter.org.eclipse.emf.henshin.interpreter.MatchgetLastMatch()org.eclipse.emf.henshin.interpreter.MatchgetResultMatch()Returns the result match of the lastapplicationof the rule of this adapter.org.eclipse.emf.henshin.model.RulegetRule()
-
-
-
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 ornullif 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
nullif the rule could not be applied
-
findMatch
public org.eclipse.emf.henshin.interpreter.Match findMatch(org.eclipse.emf.ecore.EObject emfModel)
Returns aMatchin the givenemfModelfor the rule represented by this adapter. Returnsnullif no such match exists.- Parameters:
emfModel- model to find a match in- Returns:
- a match for the rule or
nullif no match exists
-
getLastMatch
public org.eclipse.emf.henshin.interpreter.Match getLastMatch()
- Returns:
- the last match for the rule or
nullif no last match exists
-
getResultMatch
public org.eclipse.emf.henshin.interpreter.Match getResultMatch()
Returns the result match of the lastapplicationof 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-ModelNodethat 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
-
-