org.eclipse.viatra.query.runtime.api

## Class GenericQuerySpecification<Matcher extends GenericPatternMatcher>

- java.lang.Object
- - org.eclipse.viatra.query.runtime.api.impl.BaseQuerySpecification<Matcher>
  - - org.eclipse.viatra.query.runtime.api.GenericQuerySpecification<Matcher>

- All Implemented Interfaces:
    IQuerySpecification<Matcher>, PQueryHeader
  Direct Known Subclasses:
    BaseGeneratedPrivateEMFQuerySpecification, GenericQuerySpecification, GenericReferencedQuerySpecification, GenericTracedQuerySpecification

      public abstract class GenericQuerySpecification<Matcher extends GenericPatternMatcher>
      extends BaseQuerySpecification<Matcher>

  This is a generic query specification for VIATRA pattern matchers, for "interpretative" query execution. Should be subclassed by query specification implementations specific to query languages.

  When available, consider using the pattern-specific generated matcher API instead.

  The created matcher will be of type `GenericPatternMatcher`. Matches of the pattern will be represented as `GenericPatternMatch`.

  Note for overriding (if you have your own query language or ): Derived classes should use `defaultInstantiate(ViatraQueryEngine)` for implementing `BaseQuerySpecification.instantiate(ViatraQueryEngine)` if they use `GenericPatternMatcher` proper.

  Since:
    0.9
  See Also:
    `GenericPatternMatcher`, `GenericPatternMatch`, `GenericMatchProcessor`
  No Instantiate:
    This class is not intended to be instantiated by end-users.

- - ### Field Summary

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.api.impl.BaseQuerySpecification

      `wrappedPQuery`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GenericQuerySpecification(PQuery wrappedPQuery)` Instantiates query specification for the given internal query representation.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected GenericPatternMatcher` | `defaultInstantiate(ViatraQueryEngine engine)` Derived classes should use this implementation of `BaseQuerySpecification.instantiate(ViatraQueryEngine)` if they use `GenericPatternMatcher` proper.
    `GenericPatternMatch` | `newEmptyMatch()` Returns an empty, mutable Match compatible with matchers of this query.
    `GenericPatternMatch` | `newMatch(java.lang.Object... parameters)` Returns a new (partial) Match object compatible with matchers of this query.

    - ### Methods inherited from class org.eclipse.viatra.query.runtime.api.impl.BaseQuerySpecification

      `ensureInitializedInternal, ensureInitializedInternalSneaky, getAllAnnotations, getAnnotationsByName, getFirstAnnotationByName, getFullyQualifiedName, getInternalQueryRepresentation, getMatcher, getParameterNames, getParameters, getPositionOfParameter, instantiate, instantiate, processInitializerError`

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

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

    - ### Methods inherited from interface org.eclipse.viatra.query.runtime.api.IQuerySpecification

      `getPreferredScopeClass`

- - ### Constructor Detail

    - #### GenericQuerySpecification

          public GenericQuerySpecification(PQuery wrappedPQuery)

      Instantiates query specification for the given internal query representation.

  - ### Method Detail

    - #### newEmptyMatch

          public GenericPatternMatch newEmptyMatch()

      Description copied from interface: `IQuerySpecification`
      Returns an empty, mutable Match compatible with matchers of this query. 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.
      Returns:
        the empty match

    - #### newMatch

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

      Description copied from interface: `IQuerySpecification`
      Returns a new (partial) Match object compatible with matchers of this query. This can be used e.g. to call the matcher with a partial match.

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

      Parameters:
        `parameters` - the fixed value of pattern parameters, or null if not bound.
      Returns:
        the (partial) match object.

    - #### defaultInstantiate

          protected GenericPatternMatcher defaultInstantiate(ViatraQueryEngine engine)
                                                      throws ViatraQueryException

      Derived classes should use this implementation of `BaseQuerySpecification.instantiate(ViatraQueryEngine)` if they use `GenericPatternMatcher` proper.
      Throws:
        `ViatraQueryException`