Class RuleImpl

  • All Implemented Interfaces:
    org.eclipse.emf.common.notify.Notifier, org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.InternalEObject, NamedElement, Rule

    public class RuleImpl
    extends NamedElementImpl
    implements Rule
    An implementation of the model object 'Rule'.
    • Constructor Detail

      • RuleImpl

        protected RuleImpl()
        Creates a new RuleImpl.
    • Method Detail

      • eStaticClass

        protected org.eclipse.emf.ecore.EClass eStaticClass()
        Returns the EClass that correspond to this metaclass.
        Overrides:
        eStaticClass in class NamedElementImpl
        Returns:
        the EClass that correspond to this metaclass.
      • basicSetModule

        public org.eclipse.emf.common.notify.NotificationChain basicSetModule​(Module newModule,
                                                                              org.eclipse.emf.common.notify.NotificationChain msgs)
        See Also:
        setModule(Module)
      • setModule

        public void setModule​(Module newModule)
        Sets the value of the 'Module' container reference.
        Specified by:
        setModule in interface Rule
        Parameters:
        newModule - the new value of the 'Module' container reference.
        See Also:
        Rule.getModule()
      • setMode

        public void setMode​(RuleMode newMode)
        Sets the value of the 'Mode' attribute.
        Specified by:
        setMode in interface Rule
        Parameters:
        newMode - the new value of the 'Mode' attribute.
        See Also:
        RuleMode, Rule.getMode()
      • getESuperRules

        public org.eclipse.emf.common.util.EList<Rule> getESuperRules()
        Returns the value of the 'ESuper Rules' reference list. The list contents are of type Rule. It is bidirectional and its opposite is 'ESub Rules'.

        If the meaning of the 'ESuper Rules' reference list isn't clear, there really should be more of a description here...

        Specified by:
        getESuperRules in interface Rule
        Returns:
        the value of the 'ESuper Rules' reference list.
        See Also:
        EmftvmPackage.getRule_ESuperRules(), Rule.getESubRules()
      • getESubRules

        public org.eclipse.emf.common.util.EList<Rule> getESubRules()
        Returns the value of the 'ESub Rules' reference list. The list contents are of type Rule. It is bidirectional and its opposite is 'ESuper Rules'.

        If the meaning of the 'ESub Rules' reference list isn't clear, there really should be more of a description here...

        Specified by:
        getESubRules in interface Rule
        Returns:
        the value of the 'ESub Rules' reference list.
        See Also:
        EmftvmPackage.getRule_ESubRules(), Rule.getESuperRules()
      • basicSetMatcher

        public org.eclipse.emf.common.notify.NotificationChain basicSetMatcher​(CodeBlock newMatcher,
                                                                               org.eclipse.emf.common.notify.NotificationChain msgs)
        See Also:
        setMatcher(CodeBlock)
      • setMatcher

        public void setMatcher​(CodeBlock newMatcher)
        Sets the value of the 'Matcher' containment reference.
        Specified by:
        setMatcher in interface Rule
        Parameters:
        newMatcher - the new value of the 'Matcher' containment reference.
        See Also:
        Rule.getMatcher()
      • basicSetApplier

        public org.eclipse.emf.common.notify.NotificationChain basicSetApplier​(CodeBlock newApplier,
                                                                               org.eclipse.emf.common.notify.NotificationChain msgs)
        See Also:
        setApplier(CodeBlock)
      • setApplier

        public void setApplier​(CodeBlock newApplier)
        Sets the value of the 'Applier' containment reference.
        Specified by:
        setApplier in interface Rule
        Parameters:
        newApplier - the new value of the 'Applier' containment reference.
        See Also:
        Rule.getApplier()
      • basicSetPostApply

        public org.eclipse.emf.common.notify.NotificationChain basicSetPostApply​(CodeBlock newPostApply,
                                                                                 org.eclipse.emf.common.notify.NotificationChain msgs)
        See Also:
        setPostApply(CodeBlock)
      • setPostApply

        public void setPostApply​(CodeBlock newPostApply)
        Sets the value of the 'Post Apply' containment reference.
        Specified by:
        setPostApply in interface Rule
        Parameters:
        newPostApply - the new value of the 'Post Apply' containment reference.
        See Also:
        Rule.getPostApply()
      • getSuperRules

        public org.eclipse.emf.common.util.EList<java.lang.String> getSuperRules()
        Returns the value of the 'Super Rules' attribute list. The list contents are of type String.

        If the meaning of the 'Super Rules' reference list isn't clear, there really should be more of a description here...

        Specified by:
        getSuperRules in interface Rule
        Returns:
        the value of the 'Super Rules' attribute list.
        See Also:
        EmftvmPackage.getRule_SuperRules()
      • isAbstract

        public boolean isAbstract()
        Returns the value of the 'Abstract' attribute.

        If the meaning of the 'Abstract' attribute isn't clear, there really should be more of a description here...

        Specified by:
        isAbstract in interface Rule
        Returns:
        the value of the 'Abstract' attribute.
        See Also:
        Rule.setAbstract(boolean), EmftvmPackage.getRule_Abstract()
      • setAbstract

        public void setAbstract​(boolean newAbstract)
        Sets the value of the 'Abstract' attribute.
        Specified by:
        setAbstract in interface Rule
        Parameters:
        newAbstract - the new value of the 'Abstract' attribute.
        See Also:
        Rule.isAbstract()
      • getFields

        public org.eclipse.emf.common.util.EList<Field> getFields()
        Returns the value of the 'Fields' containment reference list. The list contents are of type Field. It is bidirectional and its opposite is 'Rule'.

        If the meaning of the 'Fields' containment reference list isn't clear, there really should be more of a description here...

        Specified by:
        getFields in interface Rule
        Returns:
        the value of the 'Fields' containment reference list.
        See Also:
        EmftvmPackage.getRule_Fields(), Field.getRule()
      • isDefault

        public boolean isDefault()
        Returns the value of the 'Default' attribute.

        If the meaning of the 'Default' attribute isn't clear, there really should be more of a description here...

        Specified by:
        isDefault in interface Rule
        Returns:
        the value of the 'Default' attribute.
        See Also:
        Rule.setDefault(boolean), EmftvmPackage.getRule_Default()
      • setDefault

        public void setDefault​(boolean newDefault)
        Sets the value of the 'Default' attribute.
        Specified by:
        setDefault in interface Rule
        Parameters:
        newDefault - the new value of the 'Default' attribute.
        See Also:
        Rule.isDefault()
      • isUnique

        public boolean isUnique()
        Returns the value of the 'Unique' attribute.

        A unique rule matches at most once against a unique (list of) source value(s). Traces created by a unique rule can also be efficiently lookup up, because each (list of) source value(s) maps to at most one (list of) target value(s).

        Specified by:
        isUnique in interface Rule
        Returns:
        the value of the 'Unique' attribute.
        See Also:
        Rule.setUnique(boolean), EmftvmPackage.getRule_Unique()
      • setUnique

        public void setUnique​(boolean newUnique)
        Sets the value of the 'Unique' attribute.
        Specified by:
        setUnique in interface Rule
        Parameters:
        newUnique - the new value of the 'Unique' attribute.
        See Also:
        Rule.isUnique()
      • isLeaf

        public boolean isLeaf()
        Returns the value of the 'Leaf' attribute.

        A rule is a leaf rule when it is not abstract, and it has no leaf sub-rules. Call #compileState() before calling this method.

        Specified by:
        isLeaf in interface Rule
        Returns:
        the value of the 'Leaf' attribute.
        See Also:
        EmftvmPackage.getRule_Leaf()
      • isWithLeaves

        public boolean isWithLeaves()
        Returns the value of the 'With Leaves' attribute.

        A rule is with leaves if it has leaf sub-rules. Call #compileState() before calling this method.

        Specified by:
        isWithLeaves in interface Rule
        Returns:
        the value of the 'With Leaves' attribute.
        See Also:
        EmftvmPackage.getRule_WithLeaves()
      • findField

        public Field findField​(java.lang.Object context,
                               java.lang.String name)
        Finds a Field registered within this Rule.
        Specified by:
        findField in interface Rule
        Parameters:
        context - the context type of the field
        name - the operation name
        Returns:
        the Field with the given properties, or null if none registered
      • hasField

        public boolean hasField​(java.lang.String name)
        Returns true iff this rule has any registered fields with the given name.
        Specified by:
        hasField in interface Rule
        Parameters:
        name - the field name
        Returns:
        true iff this rule has any registered fields with the given name
      • findStaticField

        public Field findStaticField​(java.lang.Object context,
                                     java.lang.String name)
        Finds a static Field registered within this Rule.
        Specified by:
        findStaticField in interface Rule
        Parameters:
        context - the context type of the field
        name - the operation name
        Returns:
        the static Field with the given properties, or null if none registered
      • hasStaticField

        public boolean hasStaticField​(java.lang.String name)
        Returns true iff this rule has any registered static fields with the given name.
        Specified by:
        hasStaticField in interface Rule
        Parameters:
        name - the field name
        Returns:
        true iff this rule has any registered static fields with the given name
      • registerField

        public void registerField​(Field field)
        Registers a Field into this Rule.
        Specified by:
        registerField in interface Rule
        Parameters:
        field - the Field to register
      • matchSingle

        public boolean matchSingle​(StackFrame frame)
        Matches this rule for the automatic single stage, if applicable. Call #compileState() before calling this method.
        Specified by:
        matchSingle in interface Rule
        Parameters:
        frame - the stack frame in which to execute the matcher
        Returns:
        true iff the rule has any matches
      • matchRecursive

        public boolean[] matchRecursive​(StackFrame frame)
        Matches this rule for the automatic recursive stage, if applicable. Call #compileState() before calling this method.
        Specified by:
        matchRecursive in interface Rule
        Parameters:
        frame - the stack frame in which to execute the matcher
        Returns:
        [true iff the rule has any matches, true iff there was a guaranteed final match]
      • matchManual

        public java.lang.Object matchManual​(StackFrame frame,
                                            java.lang.Object[] values)
        Matches this rule manually, if applicable. Call #compileState() before calling this method.
        Specified by:
        matchManual in interface Rule
        Parameters:
        frame - the stack frame in which to execute the matcher
        values - the values to match against
        Returns:
        the rule application result, or null if the rule did not match
      • matchOne

        public boolean matchOne​(StackFrame frame,
                                java.util.Map<java.lang.String,​java.lang.Object> valuesMap)
        Matches rule for valuesMap. Call #compileState() before calling this method.
        Specified by:
        matchOne in interface Rule
        Parameters:
        frame - the stack frame in which to execute the matcher
        valuesMap - the values to match against
        Returns:
        true iff the rule matches
      • matchOneOnly

        public boolean matchOneOnly​(StackFrame frame,
                                    java.util.Map<java.lang.String,​java.lang.Object> valuesMap)
        Matches this rule only (without super-rules) for valuesMap. Call #compileState() before calling this method.
        Specified by:
        matchOneOnly in interface Rule
        Parameters:
        frame - the stack frame in which to execute the matcher
        valuesMap - the values to match against
        Returns:
        true iff the rule matches
      • createTraces

        public void createTraces​(StackFrame frame)
        Creates trace elements for the recorded matches for this rule. Call #compileState() before calling this method.
        Specified by:
        createTraces in interface Rule
        Parameters:
        frame - the stack frame context
      • completeTraceFor

        public boolean completeTraceFor​(StackFrame frame,
                                        TraceLink trace)
        Completes trace for this rule by creating the output elements. Will create default/unique trace iff mapsTo information exists. Call #compileState() before calling this method.
        Specified by:
        completeTraceFor in interface Rule
        Parameters:
        frame - the stack frame context
        trace - the trace to complete
        Returns:
        true iff default/unique mappings were defined for the complete list of source elements
      • apply

        public void apply​(StackFrame frame)
        Applies this rule for the created traces. Call #compileState() before calling this method.
        Specified by:
        apply in interface Rule
        Parameters:
        frame - the stack frame in which to execute the applier
      • postApply

        public void postApply​(StackFrame frame)
        Runs post-applier for this rule for the created traces. Call #compileState() before calling this method.
        Specified by:
        postApply in interface Rule
        Parameters:
        frame - the stack frame in which to execute the post-applier
      • applyFirst

        public boolean applyFirst​(StackFrame frame)
        Applies and post-applies this rule for the first recorded match. Call #compileState() before calling this method.
        Specified by:
        applyFirst in interface Rule
        Parameters:
        frame - the stack frame in which to execute the applier and post-applier
        Returns:
        true iff this rule was applied
      • applyOne

        public java.lang.Object applyOne​(StackFrame frame,
                                         java.util.Map<java.lang.String,​java.lang.Object> valuesMap)
        Applies this rule to trace
        Specified by:
        applyOne in interface Rule
        Parameters:
        frame - the stack frame in which to execute the applier and post-apply
        valuesMap - the source and target values to which to apply the rule
        Returns:
        the rule application result
      • applyFor

        public java.lang.Object applyFor​(StackFrame frame,
                                         TraceLink trace)
        Applies this rule for the given trace. Call #compileState() before calling this method.
        Specified by:
        applyFor in interface Rule
        Parameters:
        frame - the stack frame context
        trace - the trace link to apply the rule for
        Returns:
        the application result
      • postApplyFor

        public java.lang.Object postApplyFor​(StackFrame frame,
                                             TraceLink trace)
        Post-applies this rule for the given trace. Call #compileState() before calling this method.
        Specified by:
        postApplyFor in interface Rule
        Parameters:
        frame - the stack frame context
        trace - the trace link to post-apply the rule for
        Returns:
        the post-application result
      • getAllESuperRules

        public LazySet<Rule> getAllESuperRules()
        Returns the transitive closure of super-rules, root rule first (LazySet's have a fixed iteration order). Call #compileState() before calling this method.
        Specified by:
        getAllESuperRules in interface Rule
        Returns:
        the transitive closure of super-rules.
      • createUniqueMapping

        public void createUniqueMapping​(TraceLink trace)
        Creates a unique trace mapping entry for the source values in trace, if applicable.
        Specified by:
        createUniqueMapping in interface Rule
        Parameters:
        trace - the trace element with source values
      • compileState

        public void compileState​(ExecEnv env)
        Compiles the internal state of this rule for optimised matching. Call this method whenever any properties of this rule or any sub-rules have changed.
        Specified by:
        compileState in interface Rule
        Parameters:
        env - the execution environment context
      • compileIterables

        public void compileIterables​(ExecEnv env)
        Compiles the model element iterables for this rule. Call this method whenever any input or in/out model has changed.
        Specified by:
        compileIterables in interface Rule
        Parameters:
        env - the execution environment context
      • clearFields

        public void clearFields()
        Clears the values of all registered fields within this rule.
        Specified by:
        clearFields in interface Rule
      • getUniqueTrace

        public TraceLink getUniqueTrace​(StackFrame frame,
                                        java.lang.Object[] values)
        Returns the unique rule application trace for values, if applicable.
        Specified by:
        getUniqueTrace in interface Rule
        Parameters:
        frame - the stack frame context
        values - the source values for the trace
        Returns:
        the unique rule application trace, or null
      • eInverseAdd

        public org.eclipse.emf.common.notify.NotificationChain eInverseAdd​(org.eclipse.emf.ecore.InternalEObject otherEnd,
                                                                           int featureID,
                                                                           org.eclipse.emf.common.notify.NotificationChain msgs)
        Overrides:
        eInverseAdd in class org.eclipse.emf.ecore.impl.BasicEObjectImpl
      • eInverseRemove

        public org.eclipse.emf.common.notify.NotificationChain eInverseRemove​(org.eclipse.emf.ecore.InternalEObject otherEnd,
                                                                              int featureID,
                                                                              org.eclipse.emf.common.notify.NotificationChain msgs)
        Overrides:
        eInverseRemove in class org.eclipse.emf.ecore.impl.BasicEObjectImpl
      • eBasicRemoveFromContainerFeature

        public org.eclipse.emf.common.notify.NotificationChain eBasicRemoveFromContainerFeature​(org.eclipse.emf.common.notify.NotificationChain msgs)
        Overrides:
        eBasicRemoveFromContainerFeature in class org.eclipse.emf.ecore.impl.BasicEObjectImpl
      • eGet

        public java.lang.Object eGet​(int featureID,
                                     boolean resolve,
                                     boolean coreType)
        Specified by:
        eGet in interface org.eclipse.emf.ecore.InternalEObject
        Overrides:
        eGet in class NamedElementImpl
      • eSet

        public void eSet​(int featureID,
                         java.lang.Object newValue)
        Specified by:
        eSet in interface org.eclipse.emf.ecore.InternalEObject
        Overrides:
        eSet in class NamedElementImpl
      • eUnset

        public void eUnset​(int featureID)
        Specified by:
        eUnset in interface org.eclipse.emf.ecore.InternalEObject
        Overrides:
        eUnset in class NamedElementImpl
      • eIsSet

        public boolean eIsSet​(int featureID)
        Specified by:
        eIsSet in interface org.eclipse.emf.ecore.InternalEObject
        Overrides:
        eIsSet in class NamedElementImpl
      • updateDefaultState

        protected void updateDefaultState()
        Updates defaultState.
      • updateUniqueState

        protected void updateUniqueState()
        Updates uniqueState.
      • updateSuperRulesState

        protected void updateSuperRulesState()
      • updateRuleModeState

        protected void updateRuleModeState()
        Updates ruleModeState.
      • updateLeafState

        protected void updateLeafState()
        Updates leafState.
      • updateAbstractState

        protected void updateAbstractState()
        Updates abstractState.
      • updateMatcherCbState

        protected void updateMatcherCbState()
      • updateApplierCbState

        protected void updateApplierCbState()
      • updateDistinctState

        protected void updateDistinctState()
        Updates distinctState.