Class HenshinRuleAdapter

  • Direct Known Subclasses:
    GraphRuleAdapter, MappingRuleAdapter

    public abstract class HenshinRuleAdapter
    extends Object
    Adapter between model graphs, model graph mappings and Henshin 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 given emfModel.
      org.eclipse.emf.henshin.interpreter.Match findMatch​(org.eclipse.emf.ecore.EObject emfModel)
      Returns a Match in the given emfModel for the rule represented by this adapter.
      org.eclipse.emf.henshin.interpreter.Match getLastMatch()
      Returns the last Match created by a call to findMatch(EObject) or applyRule(EObject, Match).
      org.eclipse.emf.henshin.interpreter.Match getResultMatch()
      Returns the result match of the last application of the rule of this adapter.
      org.eclipse.emf.henshin.model.Rule getRule()  
    • Field Detail

      • rule

        protected org.eclipse.emf.henshin.model.Rule rule
      • match

        protected org.eclipse.emf.henshin.interpreter.Match match
      • resultMatch

        protected org.eclipse.emf.henshin.interpreter.Match resultMatch
    • Constructor Detail

      • HenshinRuleAdapter

        protected HenshinRuleAdapter​(org.eclipse.emf.henshin.interpreter.Engine engine)
    • 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 given emfModel. 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 or null if the rule could not be applied.
        Parameters:
        emfModel - model to apply the rule to
        partialMatch - 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 a Match in the given emfModel for the rule represented by this adapter. Returns null 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 created by a call to findMatch(EObject) or applyRule(EObject, Match).
        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 last application 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
      • 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 rule
        ignoredAttributes - attributes not considered for the given node
        cRule - rule to extend
        action - action type of the added rule node
        Returns:
        the added rule node