org.eclipse.incquery.patternlanguage.emf.specification

## Class SpecificationBuilder

- java.lang.Object
- - org.eclipse.incquery.patternlanguage.emf.specification.SpecificationBuilder

-     public class SpecificationBuilder
      extends java.lang.Object

  An instance class to initialize `PBody` instances from `Pattern` definitions. A single instance of this builder is used during construction, that maintains the mapping between `Pattern` and `PQuery` objects, and can be initialized with a pre-defined set of mappings.

  The SpecificationBuilder is stateful: it stores all previously built specifications, allowing further re-use.

  Author:
    Zoltan Ujhelyi

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SpecificationBuilder()` Initializes a query builder with no previously known query specifications
    `SpecificationBuilder(java.util.Collection<? extends IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>>> specifications)` Sets up a query builder with a predefined collection of specifications
    `SpecificationBuilder(IQuerySpecification<?>... specifications)` Sets up a query builder with a predefined set of specifications
    `SpecificationBuilder(NameToSpecificationMap patternMap)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.util.Set<PBody>` | `buildBodies(Pattern pattern, InitializablePQuery query)`
    `void` | `forgetSpecification(IQuerySpecification<?> specification)` Forgets a specification in the builder.
    `java.util.Set<IQuerySpecification<?>>` | `forgetSpecificationTransitively(IQuerySpecification<?> specification)` Forgets a specification in the builder, and also removes anything that depends on it.
    `java.util.Set<PBody>` | `getBodies(Pattern pattern, PQuery query)`
    `IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>>` | `getOrCreateSpecification(Pattern pattern)` Creates a new or returns an existing query specification for the pattern.
    `IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>>` | `getOrCreateSpecification(Pattern pattern, boolean skipPatternValidation)` Creates a new or returns an existing query specification for the pattern.
    `IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>>` | `getOrCreateSpecification(Pattern pattern, java.util.List<IQuerySpecification<?>> createdPatternList, boolean skipPatternValidation)`
    `IQuerySpecification<?>` | `getSpecification(Pattern pattern)`
    `IQuerySpecification<?>` | `getSpecification(java.lang.String fqn)`

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

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

- - ### Constructor Detail

    - #### SpecificationBuilder

          public SpecificationBuilder()

      Initializes a query builder with no previously known query specifications

    - #### SpecificationBuilder

          public SpecificationBuilder(IQuerySpecification<?>... specifications)

      Sets up a query builder with a predefined set of specifications

    - #### SpecificationBuilder

          public SpecificationBuilder(java.util.Collection<? extends IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>>> specifications)

      Sets up a query builder with a predefined collection of specifications

    - #### SpecificationBuilder

          public SpecificationBuilder(NameToSpecificationMap patternMap)

  - ### Method Detail

    - #### getOrCreateSpecification

          public IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>> getOrCreateSpecification(Pattern pattern)
                                                                                                           throws IncQueryException

      Creates a new or returns an existing query specification for the pattern. It is expected, that the builder will not be called with different patterns having the same fqn over its entire lifecycle.
      Parameters:
        `pattern` -
      Throws:
        `IncQueryException`

    - #### getOrCreateSpecification

          public IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>> getOrCreateSpecification(Pattern pattern,
                                                                                                                  boolean skipPatternValidation)
                                                                                                           throws IncQueryException

      Creates a new or returns an existing query specification for the pattern. It is expected, that the builder will not be called with different patterns having the same fqn over its entire lifecycle.
      Parameters:
        `pattern` -
        `skipPatternValidation` - if set to true, detailed pattern validation is skipped - true for model inferrer; not recommended for generic API
      Throws:
        `IncQueryException`

    - #### getOrCreateSpecification

          public IQuerySpecification<? extends IncQueryMatcher<? extends IPatternMatch>> getOrCreateSpecification(Pattern pattern,
                                                                                                                  java.util.List<IQuerySpecification<?>> createdPatternList,
                                                                                                                  boolean skipPatternValidation)
                                                                                                           throws IncQueryException

      Throws:
        `IncQueryException`

    - #### buildBodies

          public java.util.Set<PBody> buildBodies(Pattern pattern,
                                                  InitializablePQuery query)
                                           throws QueryInitializationException

      Throws:
        `QueryInitializationException`

    - #### getBodies

          public java.util.Set<PBody> getBodies(Pattern pattern,
                                                PQuery query)
                                         throws QueryInitializationException

      Throws:
        `QueryInitializationException`

    - #### getSpecification

          public IQuerySpecification<?> getSpecification(Pattern pattern)

    - #### getSpecification

          public IQuerySpecification<?> getSpecification(java.lang.String fqn)

    - #### forgetSpecification

          public void forgetSpecification(IQuerySpecification<?> specification)

      Forgets a specification in the builder.

      Warning! Removing a specification does not change any specification created previously, even if they are referring to the old version of the specification. Only use this if you are sure all dependant queries are also removed, otherwise use `forgetSpecificationTransitively(IQuerySpecification)` instead.

    - #### forgetSpecificationTransitively

          public java.util.Set<IQuerySpecification<?>> forgetSpecificationTransitively(IQuerySpecification<?> specification)

      Forgets a specification in the builder, and also removes anything that depends on it.
      Parameters:
        `specification` -