Package org.eclipse.viatra.query.patternlanguage.emf.specification

## Class GenericEMFPatternPQuery

- java.lang.Object
- - org.eclipse.viatra.query.runtime.matchers.psystem.queries.BasePQuery
  - - org.eclipse.viatra.query.patternlanguage.emf.specification.GenericEMFPatternPQuery

- All Implemented Interfaces:
    `InitializablePQuery`, `PTraceable`, `PQuery`, `PQueryHeader`

      public class GenericEMFPatternPQuery
      extends BasePQuery
      implements InitializablePQuery

  This is a generic (i.e. not pattern-specific) class for the internal representation of VIATRA queries, for "interpretative" query execution.

  End users should use {link GenericQuerySpecification} instead.

  No Instantiate:
    This class is not intended to be instantiated by clients

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery

      `PQuery.PQueryStatus`

  - ### Field Summary

    - ### Fields inherited from class org.eclipse.viatra.query.runtime.matchers.psystem.queries.BasePQuery

      `pProblems, status, visibility`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `GenericEMFPatternPQuery​(Pattern pattern)` | Initializes a generic query representation for a given pattern.
    `GenericEMFPatternPQuery​(Pattern pattern, boolean delayedInitialization)` | Initializes a generic query specification for a given pattern.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addAnnotation​(PAnnotation annotation)` | Adds an annotation to the specification.
    `void` | `addError​(PProblem problem)` | Adds a detected error.
    `protected java.util.Set<PBody>` | `doGetContainedBodies()` | Creates and returns the bodies of the query.
    `boolean` | `equals​(java.lang.Object obj)` |
    `PDisjunction` | `getDisjunctBodies()` | Returns all bodies associated with the query in their canonical form.
    `java.lang.String` | `getFullyQualifiedName()` | Identifies the pattern for which matchers can be instantiated.
    `java.util.List<PParameter>` | `getParameters()` | Returns a list of parameter descriptions
    `Pattern` | `getPattern()` |
    `int` | `hashCode()` |
    `void` | `initializeBodies​(java.util.Set<PBody> bodies)` | Sets up the bodies of the pattern.
    `void` | `setStatus​(PQuery.PQueryStatus newStatus)` | Sets the query status.

    - ### Methods inherited from class org.eclipse.viatra.query.runtime.matchers.psystem.queries.BasePQuery

      `checkMutability, ensureInitialized, getAllAnnotations, getAllReferredQueries, getAnnotationsByName, getDirectReferredQueries, getEvaluationHints, getFirstAnnotationByName, getParameterNames, getPositionOfParameter, getPProblems, getStatus, getTypeGuarantees, getVisibility, isMutable, publishedAs, setBodies, setEvaluationHints, toString`

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQuery

      `checkMutability, ensureInitialized, getAllReferredQueries, getDirectReferredQueries, getEvaluationHints, getPProblems, getStatus, getTypeGuarantees, isMutable, publishedAs`

    - ### Methods inherited from interface org.eclipse.viatra.query.runtime.matchers.psystem.queries.PQueryHeader

      `getAllAnnotations, getAnnotationsByName, getFirstAnnotationByName, getParameter, getParameterNames, getPositionOfParameter, getSimpleName, getVisibility`

- - ### Constructor Detail

    - #### GenericEMFPatternPQuery

          public GenericEMFPatternPQuery​(Pattern pattern)

      Initializes a generic query representation for a given pattern.

      Warning: it is not recommended to directly instantiate GenericPQuery instances as they will not reuse previously built specifications- use `SpecificationBuilder` instead.

      Parameters:
        `pattern` - the pattern for which the matcher is to be constructed.
      Throws:
        `ViatraQueryRuntimeException`
      Since:
        2.0

    - #### GenericEMFPatternPQuery

          public GenericEMFPatternPQuery​(Pattern pattern,
                                         boolean delayedInitialization)

      Initializes a generic query specification for a given pattern.
      Parameters:
        `pattern` - the pattern for which matchers are to be constructed.
        `delayedInitialization` - true if the query is not created automatically - in this case before use the `initializeBodies(Set)` method
      Throws:
        `ViatraQueryRuntimeException`
      Since:
        2.0

  - ### Method Detail

    - #### getPattern

          public Pattern getPattern()

      Since:
        2.0

    - #### equals

          public boolean equals​(java.lang.Object obj)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### getFullyQualifiedName

          public java.lang.String getFullyQualifiedName()

      Description copied from interface: `PQueryHeader`
      Identifies the pattern for which matchers can be instantiated.
      Specified by:
        `getFullyQualifiedName` in interface `PQueryHeader`

    - #### getParameters

          public java.util.List<PParameter> getParameters()

      Description copied from interface: `PQueryHeader`
      Returns a list of parameter descriptions
      Specified by:
        `getParameters` in interface `PQueryHeader`
      Returns:
        a non-null, but possibly empty list of parameter descriptions

    - #### getDisjunctBodies

          public PDisjunction getDisjunctBodies()

      Description copied from interface: `PQuery`
      Returns all bodies associated with the query in their canonical form. If called multiple times, the same set with the same contents will be returned.
      Specified by:
        `getDisjunctBodies` in interface `PQuery`
      Overrides:
        `getDisjunctBodies` in class `BasePQuery`

    - #### addAnnotation

          public void addAnnotation​(PAnnotation annotation)

      Description copied from interface: `InitializablePQuery`
      Adds an annotation to the specification. Only applicable if the pattern is still `uninitialized`.
      Specified by:
        `addAnnotation` in interface `InitializablePQuery`
      Overrides:
        `addAnnotation` in class `BasePQuery`

    - #### doGetContainedBodies

          protected java.util.Set<PBody> doGetContainedBodies()

      Description copied from class: `BasePQuery`
      Creates and returns the bodies of the query. If recalled again, a new instance is created.
      Specified by:
        `doGetContainedBodies` in class `BasePQuery`
      Returns:

    - #### initializeBodies

          public void initializeBodies​(java.util.Set<PBody> bodies)

      Description copied from interface: `InitializablePQuery`
      Sets up the bodies of the pattern. Only applicable if the pattern is still `uninitialized`.
      Specified by:
        `initializeBodies` in interface `InitializablePQuery`

    - #### setStatus

          public final void setStatus​(PQuery.PQueryStatus newStatus)

      Description copied from interface: `InitializablePQuery`
      Sets the query status. Only applicable if the pattern is still `uninitialized`.
      Specified by:
        `setStatus` in interface `InitializablePQuery`
      Overrides:
        `setStatus` in class `BasePQuery`
      Parameters:
        `newStatus` - the new status

    - #### addError

          public void addError​(PProblem problem)

      Description copied from interface: `InitializablePQuery`
      Adds a detected error. Only applicable if the pattern is still `uninitialized`.
      Specified by:
        `addError` in interface `InitializablePQuery`
      Overrides:
        `addError` in class `BasePQuery`
      Parameters:
        `problem` - the new problem