org.eclipse.viatra.query.runtime.api.impl

## Class BaseMatcher<Match extends IPatternMatch>

- java.lang.Object
- - org.eclipse.viatra.query.runtime.internal.apiimpl.QueryResultWrapper
  - - org.eclipse.viatra.query.runtime.api.impl.BaseMatcher<Match>

- Type Parameters:
    `Match` -
  All Implemented Interfaces:
    ViatraQueryMatcher<Match>
  Direct Known Subclasses:
    ActionContextMatcher, ActionInputMatcher, ActionOutputMatcher, ActivityEdgeInGroupMatcher, ActivityGroupContainedEdgeMatcher, ActivityGroupContainedNodeMatcher, ActivityGroupInActivityMatcher, ActivityGroupMatcher, ActivityGroupSubgroupMatcher, ActivityGroupSuperGroupMatcher, ActivityNodeActivityMatcher, ActivityNodeInGroupMatcher, ActivityNodeMatcher, AndPatternMatcher, AssociationEndTypeMatcher, AtomicEventPatternMatcher, BehaviorContextMatcher, ChildrenMatcher, ClassExtensionMatcher, ClassifierAttributeMatcher, ClassifierFeatureMatcher, ClassifierGeneralMatcher, ClassSuperClassMatcher, ComplexAndTransitionMatcher, ComplexFollowsTransitionMatcher, ComplexNotTransitionMatcher, ComplexOrTransitionMatcher, ConnectableElementEndMatcher, ConnectorKindMatcher, DeploymentTargetDeployedElementMatcher, DirectedRelationshipSourceMatcher, DirectedRelationshipTargetMatcher, ElementOwnedElementMatcher, ElementOwnerMatcher, EmptyTraceMatcher, EnabledNegativeTransitionMatcher, EnabledTransitionMatcher, EncapsulatedClassifierOwnedPortMatcher, EpsilonTransitionMatcher, EquivalentStatesMatcher, EquivalentTransitionsMatcher, EventProcessedByEventTokenMatcher, EventTokensInModelMatcher, ExtensionMetaclassMatcher, FeatureFeaturingClassifierMatcher, FinalStatesMatcher, FinishedAutomatonMatcher, FollowsPatternMatcher, GenericPatternMatcher, InitialStateMatcher, InitStateMatcher, LatestEventMatcher, MessageMessageKindMatcher, NamedElementClientDependencyMatcher, NamedElementNamespaceMatcher, NamedElementQualifiedNameMatcher, NamespaceImportedMemberMatcher, NamespaceMemberMatcher, NamespaceOwnedMemberMatcher, NegativeTransitionMatcher, NegativeTransitionMatcher, NonUnfoldedNotTransitionMatcher, NotPatternMatcher, OpaqueExpressionResultMatcher, OrPatternMatcher, PackageNestedPackageMatcher, PackageNestingPackageMatcher, PackageOwnedStereotypeMatcher, PackageOwnedTypeMatcher, Param2containmentMatcher, Param2edgeMatcher, Param2itemMatcher, Param2targetMatcher, PartiallyMatchedEventPatternMatcher, PropertyIsCompositeMatcher, ProtocolTransitionReferredMatcher, RedefinableElementRedefinedElementMatcher, RedefinableElementRedefinitionContextMatcher, RedefinableTemplateSignatureInheritedParameterMatcher, RelationshipRelatedElementMatcher, ResettableEventTokenMatcher, StateIsCompositeMatcher, StateIsOrthogonalMatcher, StructuredClassifierPartMatcher, StructuredClassifierRoleMatcher, TokenEntersTimedZoneMatcher, TokenInFinalStateMatcher, TokenInInitStateMatcher, TokenInTimedZoneMatcher, TokenInTrapStateMatcher, TokenLeavesTimedZoneMatcher, Trace2objectMatcher, Trace2paramMatcher, Trace2targetMatcher, TraceMatcher, TransitionWithEventTypeMatcher, TranslatedEventPatternMatcher, TrapStateMatcher, TypePackageMatcher, VertexIncomingMatcher, VertexOutgoingMatcher

      public abstract class BaseMatcher<Match extends IPatternMatch>
      extends org.eclipse.viatra.query.runtime.internal.apiimpl.QueryResultWrapper
      implements ViatraQueryMatcher<Match>

  Base implementation of ViatraQueryMatcher.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ViatraQueryEngine` | `engine`
    `protected IQuerySpecification<? extends BaseMatcher<Match>>` | `querySpecification`

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.internal.apiimpl.QueryResultWrapper

      `backend`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BaseMatcher(IQuerySpecification<? extends BaseMatcher<Match>> querySpecification)`
    `BaseMatcher(ViatraQueryEngine engine, IQuerySpecification<? extends BaseMatcher<Match>> querySpecification)` Deprecated. Since 1.4, generated code uses `BaseMatcher(IQuerySpecification)`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract Match` | `arrayToMatch(java.lang.Object[] parameters)` Converts the array representation of a pattern match to an immutable Match object.
    `protected abstract Match` | `arrayToMatchMutable(java.lang.Object[] parameters)` Converts the array representation of a pattern match to a mutable Match object.
    `int` | `countMatches()` Returns the number of all pattern matches.
    `int` | `countMatches(Match partialMatch)` Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
    `protected java.lang.Object[]` | `emptyArray()`
    `void` | `forEachMatch(IMatchProcessor<? super Match> processor)` Executes the given processor on each match of the pattern.
    `void` | `forEachMatch(Match match, IMatchProcessor<? super Match> processor)` Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters.
    `boolean` | `forOneArbitraryMatch(IMatchProcessor<? super Match> processor)` Executes the given processor on an arbitrarily chosen match of the pattern.
    `boolean` | `forOneArbitraryMatch(Match partialMatch, IMatchProcessor<? super Match> processor)` Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
    `java.util.Collection<Match>` | `getAllMatches()` Returns the set of all pattern matches.
    `java.util.Collection<Match>` | `getAllMatches(Match partialMatch)` Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
    `java.util.Set<java.lang.Object>` | `getAllValues(java.lang.String parameterName)` Retrieve the set of values that occur in matches for the given parameterName.
    `java.util.Set<java.lang.Object>` | `getAllValues(java.lang.String parameterName, Match partialMatch)` Retrieve the set of values that occur in matches for the given parameterName, that conforms to the given fixed values of some parameters.
    `IMatcherCapability` | `getCapabilities()`
    `ViatraQueryEngine` | `getEngine()` Returns the engine that the matcher uses.
    `Match` | `getOneArbitraryMatch()` Returns an arbitrarily chosen pattern match.
    `Match` | `getOneArbitraryMatch(Match partialMatch)` Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
    `java.util.List<java.lang.String>` | `getParameterNames()` Returns the array of symbolic parameter names.
    `java.lang.String` | `getPatternName()` Fully qualified name of the pattern.
    `java.lang.Integer` | `getPositionOfParameter(java.lang.String parameterName)` Returns the index of the symbolic parameter with the given name.
    `IQuerySpecification<? extends BaseMatcher<Match>>` | `getSpecification()` The pattern that will be matched.
    `boolean` | `hasMatch(Match partialMatch)` Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, under any possible substitution of the unspecified parameters (if any).
    `protected java.lang.Object[]` | `matchToArray(Match partialMatch)` Converts the Match object of a pattern match to the array representation.
    `Match` | `newEmptyMatch()` Returns an empty, mutable Match for the matcher.
    `Match` | `newMatch(java.lang.Object... parameters)` Returns a new (partial) Match object for the matcher.
    `protected <T> void` | `rawAccumulateAllValues(int position, java.lang.Object[] parameters, java.util.Set<T> accumulator)` Uses an existing set to accumulate all values of the parameter with the given name.
    `protected int` | `rawCountMatches(java.lang.Object[] parameters)` Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
    `protected void` | `rawForEachMatch(java.lang.Object[] parameters, IMatchProcessor<? super Match> processor)` Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters.
    `protected boolean` | `rawForOneArbitraryMatch(java.lang.Object[] parameters, IMatchProcessor<? super Match> processor)` Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
    `protected java.util.Collection<Match>` | `rawGetAllMatches(java.lang.Object[] parameters)` Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
    `protected java.util.Set<java.lang.Object>` | `rawGetAllValues(int position, java.lang.Object[] parameters)` Retrieve the set of values that occur in matches for the given parameterName, that conforms to the given fixed values of some parameters.
    `protected Match` | `rawGetOneArbitraryMatch(java.lang.Object[] parameters)` Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
    `protected boolean` | `rawHasMatch(java.lang.Object[] parameters)` Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, under any possible substitution of the unspecified parameters.
    `protected void` | `setBackend(ViatraQueryEngine engine, IQueryResultProvider resultProvider, IMatcherCapability capabilities)`
    `protected abstract Match` | `tupleToMatch(Tuple t)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### engine

          protected ViatraQueryEngine engine

    - #### querySpecification

          protected IQuerySpecification<? extends BaseMatcher<Match extends IPatternMatch>> querySpecification

  - ### Constructor Detail

    - #### BaseMatcher

          public BaseMatcher(IQuerySpecification<? extends BaseMatcher<Match>> querySpecification)
                      throws ViatraQueryException

      Throws:
        `ViatraQueryException`
      Since:
        1.4

    - #### BaseMatcher

          @Deprecated
          public BaseMatcher(ViatraQueryEngine engine,
                                         IQuerySpecification<? extends BaseMatcher<Match>> querySpecification)
                                  throws ViatraQueryException

      Deprecated. Since 1.4, generated code uses `BaseMatcher(IQuerySpecification)`
      Throws:
        `ViatraQueryException`

  - ### Method Detail

    - #### setBackend

          protected void setBackend(ViatraQueryEngine engine,
                                    IQueryResultProvider resultProvider,
                                    IMatcherCapability capabilities)

      Specified by:
        `setBackend` in class `org.eclipse.viatra.query.runtime.internal.apiimpl.QueryResultWrapper`
      Since:
        1.4

    - #### arrayToMatch

          protected abstract Match arrayToMatch(java.lang.Object[] parameters)

      Converts the array representation of a pattern match to an immutable Match object.

    - #### arrayToMatchMutable

          protected abstract Match arrayToMatchMutable(java.lang.Object[] parameters)

      Converts the array representation of a pattern match to a mutable Match object.

    - #### matchToArray

          protected java.lang.Object[] matchToArray(Match partialMatch)

      Converts the Match object of a pattern match to the array representation.

    - #### tupleToMatch

          protected abstract Match tupleToMatch(Tuple t)

    - #### emptyArray

          protected java.lang.Object[] emptyArray()

    - #### getPositionOfParameter

          public java.lang.Integer getPositionOfParameter(java.lang.String parameterName)

      Description copied from interface: `ViatraQueryMatcher`
      Returns the index of the symbolic parameter with the given name.
      Specified by:
        `getPositionOfParameter` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`

    - #### getParameterNames

          public java.util.List<java.lang.String> getParameterNames()

      Description copied from interface: `ViatraQueryMatcher`
      Returns the array of symbolic parameter names.
      Specified by:
        `getParameterNames` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`

    - #### getAllMatches

          public java.util.Collection<Match> getAllMatches()

      Description copied from interface: `ViatraQueryMatcher`
      Returns the set of all pattern matches.
      Specified by:
        `getAllMatches` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Returns:
        matches represented as a Match object.

    - #### rawGetAllMatches

          protected java.util.Collection<Match> rawGetAllMatches(java.lang.Object[] parameters)

      Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
      Parameters:
        `parameters` - array where each non-null element binds the corresponding pattern parameter to a fixed value.
      Returns:
        matches represented as a Match object.

    - #### getAllMatches

          public java.util.Collection<Match> getAllMatches(Match partialMatch)

      Description copied from interface: `ViatraQueryMatcher`
      Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
      Specified by:
        `getAllMatches` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Parameters:
        `partialMatch` - a partial match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.
      Returns:
        matches represented as a Match object.

    - #### getOneArbitraryMatch

          public Match getOneArbitraryMatch()

      Description copied from interface: `ViatraQueryMatcher`
      Returns an arbitrarily chosen pattern match. Neither determinism nor randomness of selection is guaranteed.
      Specified by:
        `getOneArbitraryMatch` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Returns:
        a match represented as a Match object, or null if no match is found.

    - #### rawGetOneArbitraryMatch

          protected Match rawGetOneArbitraryMatch(java.lang.Object[] parameters)

      Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. Neither determinism nor randomness of selection is guaranteed.
      Parameters:
        `parameters` - array where each non-null element binds the corresponding pattern parameter to a fixed value.
      Returns:
        a match represented as a Match object, or null if no match is found.

    - #### getOneArbitraryMatch

          public Match getOneArbitraryMatch(Match partialMatch)

      Description copied from interface: `ViatraQueryMatcher`
      Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. Neither determinism nor randomness of selection is guaranteed.
      Specified by:
        `getOneArbitraryMatch` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Parameters:
        `partialMatch` - a partial match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.
      Returns:
        a match represented as a Match object, or null if no match is found.

    - #### rawHasMatch

          protected boolean rawHasMatch(java.lang.Object[] parameters)

      Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, under any possible substitution of the unspecified parameters.
      Parameters:
        `parameters` - array where each non-null element binds the corresponding pattern parameter to a fixed value.
      Returns:
        true if the input is a valid (partial) match of the pattern.

    - #### hasMatch

          public boolean hasMatch(Match partialMatch)

      Description copied from interface: `ViatraQueryMatcher`
      Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, under any possible substitution of the unspecified parameters (if any).
      Specified by:
        `hasMatch` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Parameters:
        `partialMatch` - a (partial) match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.
      Returns:
        true if the input is a valid (partial) match of the pattern.

    - #### countMatches

          public int countMatches()

      Description copied from interface: `ViatraQueryMatcher`
      Returns the number of all pattern matches.
      Specified by:
        `countMatches` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Returns:
        the number of pattern matches found.

    - #### rawCountMatches

          protected int rawCountMatches(java.lang.Object[] parameters)

      Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
      Parameters:
        `parameters` - array where each non-null element binds the corresponding pattern parameter to a fixed value.
      Returns:
        the number of pattern matches found.

    - #### countMatches

          public int countMatches(Match partialMatch)

      Description copied from interface: `ViatraQueryMatcher`
      Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
      Specified by:
        `countMatches` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Parameters:
        `partialMatch` - a partial match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.
      Returns:
        the number of pattern matches found.

    - #### rawForEachMatch

          protected void rawForEachMatch(java.lang.Object[] parameters,
                                         IMatchProcessor<? super Match> processor)

      Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters.
      Parameters:
        `parameters` - array where each non-null element binds the corresponding pattern parameter to a fixed value.
        `action` - the action that will process each pattern match.

    - #### forEachMatch

          public void forEachMatch(IMatchProcessor<? super Match> processor)

      Description copied from interface: `ViatraQueryMatcher`
      Executes the given processor on each match of the pattern.
      Specified by:
        `forEachMatch` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Parameters:
        `processor` - the action that will process each pattern match.

    - #### forEachMatch

          public void forEachMatch(Match match,
                                   IMatchProcessor<? super Match> processor)

      Description copied from interface: `ViatraQueryMatcher`
      Executes the given processor on each match of the pattern that conforms to the given fixed values of some parameters.
      Specified by:
        `forEachMatch` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Parameters:
        `match` - array where each non-null element binds the corresponding pattern parameter to a fixed value.
        `processor` - the action that will process each pattern match.

    - #### forOneArbitraryMatch

          public boolean forOneArbitraryMatch(IMatchProcessor<? super Match> processor)

      Description copied from interface: `ViatraQueryMatcher`
      Executes the given processor on an arbitrarily chosen match of the pattern. Neither determinism nor randomness of selection is guaranteed.
      Specified by:
        `forOneArbitraryMatch` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Parameters:
        `processor` - the action that will process the selected match.
      Returns:
        true if the pattern has at least one match, false if the processor was not invoked

    - #### forOneArbitraryMatch

          public boolean forOneArbitraryMatch(Match partialMatch,
                                              IMatchProcessor<? super Match> processor)

      Description copied from interface: `ViatraQueryMatcher`
      Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. Neither determinism nor randomness of selection is guaranteed.
      Specified by:
        `forOneArbitraryMatch` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Parameters:
        `partialMatch` - array where each non-null element binds the corresponding pattern parameter to a fixed value.
        `processor` - the action that will process the selected match.
      Returns:
        true if the pattern has at least one match with the given parameter values, false if the processor was not invoked

    - #### rawForOneArbitraryMatch

          protected boolean rawForOneArbitraryMatch(java.lang.Object[] parameters,
                                                    IMatchProcessor<? super Match> processor)

      Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. Neither determinism nor randomness of selection is guaranteed.
      Parameters:
        `parameters` - array where each non-null element binds the corresponding pattern parameter to a fixed value.
        `processor` - the action that will process the selected match.
      Returns:
        true if the pattern has at least one match with the given parameter values, false if the processor was not invoked

    - #### newEmptyMatch

          public Match newEmptyMatch()

      Description copied from interface: `ViatraQueryMatcher`
      Returns an empty, mutable Match for the matcher. Fields of the mutable match can be filled to create a partial match, usable as matcher input. This can be used to call the matcher with a partial match even if the specific class of the matcher or the match is unknown.
      Specified by:
        `newEmptyMatch` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Returns:
        the empty match

    - #### newMatch

          public Match newMatch(java.lang.Object... parameters)

      Description copied from interface: `ViatraQueryMatcher`
      Returns a new (partial) Match object for the matcher. This can be used e.g. to call the matcher with a partial match.

      The returned match will be immutable. Use `ViatraQueryMatcher.newEmptyMatch()` to obtain a mutable match object.

      Specified by:
        `newMatch` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Parameters:
        `parameters` - the fixed value of pattern parameters, or null if not bound.
      Returns:
        the (partial) match object.

    - #### getAllValues

          public java.util.Set<java.lang.Object> getAllValues(java.lang.String parameterName)

      Description copied from interface: `ViatraQueryMatcher`
      Retrieve the set of values that occur in matches for the given parameterName.
      Specified by:
        `getAllValues` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Parameters:
        `parameterName` - name of the parameter for which values are returned
      Returns:
        the Set of all values for the given parameter, null if the parameter with the given name does not exists, empty set if there are no matches

    - #### getAllValues

          public java.util.Set<java.lang.Object> getAllValues(java.lang.String parameterName,
                                                              Match partialMatch)

      Description copied from interface: `ViatraQueryMatcher`
      Retrieve the set of values that occur in matches for the given parameterName, that conforms to the given fixed values of some parameters.
      Specified by:
        `getAllValues` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Parameters:
        `parameterName` - name of the parameter for which values are returned
        `partialMatch` - a partial match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.
      Returns:
        the Set of all values for the given parameter, null if the parameter with the given name does not exists or if the parameter with the given name is set in partialMatch, empty set if there are no matches

    - #### rawGetAllValues

          protected java.util.Set<java.lang.Object> rawGetAllValues(int position,
                                                                    java.lang.Object[] parameters)

      Retrieve the set of values that occur in matches for the given parameterName, that conforms to the given fixed values of some parameters.
      Parameters:
        `position` - position of the parameter for which values are returned
        `parameters` - a parameter array corresponding to a partial match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.
      Returns:
        the Set of all values in the given position, null if no parameter with the given position exists or if parameters[position] is set, empty set if there are no matches

    - #### rawAccumulateAllValues

          protected <T> void rawAccumulateAllValues(int position,
                                                    java.lang.Object[] parameters,
                                                    java.util.Set<T> accumulator)

      Uses an existing set to accumulate all values of the parameter with the given name. Since it is a protected method, no error checking or input validation is performed!
      Parameters:
        `position` - position of the parameter for which values are returned
        `parameters` - a parameter array corresponding to a partial match of the pattern where each non-null field binds the corresponding pattern parameter to a fixed value.
        `accumulator` - the existing set to fill with the values

    - #### getEngine

          public ViatraQueryEngine getEngine()

      Description copied from interface: `ViatraQueryMatcher`
      Returns the engine that the matcher uses.
      Specified by:
        `getEngine` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`
      Returns:
        the engine

    - #### getSpecification

          public IQuerySpecification<? extends BaseMatcher<Match>> getSpecification()

      Description copied from interface: `ViatraQueryMatcher`
      The pattern that will be matched.
      Specified by:
        `getSpecification` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`

    - #### getPatternName

          public java.lang.String getPatternName()

      Description copied from interface: `ViatraQueryMatcher`
      Fully qualified name of the pattern.
      Specified by:
        `getPatternName` in interface `ViatraQueryMatcher<Match extends IPatternMatch>`

    - #### getCapabilities

          public IMatcherCapability getCapabilities()

      Since:
        1.4