org.eclipse.viatra.query.tooling.ui.queryexplorer.util

## Class QueryExplorerPatternRegistry

- java.lang.Object
- - org.eclipse.viatra.query.tooling.ui.queryexplorer.util.QueryExplorerPatternRegistry

-     public class QueryExplorerPatternRegistry
      extends java.lang.Object

  Utility class used by the Query Explorer for the maintenance of registered patterns.

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `QueryExplorerPatternRegistry()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addActivePattern(IQuerySpecification<?> p)` Sets the given pattern as active ("checks on the Query Explorer").
    `void` | `addGeneratedPattern(IQuerySpecification<?> specification)`
    `java.util.List<IQuerySpecification<?>>` | `getActivePatterns()` Returns the list of active patterns.
    `java.util.List<IQuerySpecification<?>>` | `getAllPatterns()` Return a list of all known patterns.
    `org.eclipse.core.resources.IFile` | `getFileForPattern(IQuerySpecification<?> pattern)` Returns the vql file instance that the given pattern can be found in.
    `java.util.Collection<org.eclipse.core.resources.IFile>` | `getFiles()` Returns the list of vql files from which patterns are registered.
    `static com.google.common.collect.ImmutableList<IQuerySpecification<?>>` | `getGeneratedQuerySpecifications()` access the list of "generated" query specifications
    `java.util.Collection<IQuerySpecification<?>>` | `getGenericQuerySpecifications()` Returns the list of (generic) patterns registered in the registry.
    `static QueryExplorerPatternRegistry` | `getInstance()`
    `IQuerySpecification<?>` | `getPatternByFqn(java.lang.String patternFqn)` Returns the pattern associated with the given fully qualified name.
    `java.util.Collection<java.lang.String>` | `getPatternNames()` Returns the names of the patterns registered in the registry.
    `static com.google.common.base.Optional<java.lang.Boolean>` | `getQueryExplorerCheckedValue(IQuerySpecification<?> query)` Returns an Optional that has value if the user declared "@QueryExplorer(checked=value)" on the pattern.
    `java.util.List<IQuerySpecification<?>>` | `getRegisteredPatternsForFile(org.eclipse.core.resources.IFile file)` Returns the (unmodifiable) list of registered patterns from the given file.
    `boolean` | `isActive(java.lang.String patternFqn)` Returns true if the given pattern is currently active, false otherwise.
    `boolean` | `isEmpty()` Returns true if there are no (generic) patterns registered, false otherwise.
    `boolean` | `isGenerated(IQuerySpecification<?> query)`
    `java.util.Set<IQuerySpecification<?>>` | `registerPatternModel(org.eclipse.core.resources.IFile file, PatternModel patternModel)` Registers the patterns within the given (parsed) pattern model.
    `void` | `removeActivePattern(IQuerySpecification<?> p)` Sets the given pattern as passive.
    `void` | `removeActivePattern(java.lang.String patternFqn)`
    `java.util.List<IQuerySpecification<?>>` | `unregisterPattern(IQuerySpecification<?> specification)` Unregisters the given pattern from the registry.
    `java.util.List<IQuerySpecification<?>>` | `unregisterPatternModel(org.eclipse.core.resources.IFile file)` Unregisters the patterns within the given vql file and returns the list of those patterns that were currently active from the given file.

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

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

- - ### Constructor Detail

    - #### QueryExplorerPatternRegistry

          protected QueryExplorerPatternRegistry()

  - ### Method Detail

    - #### getInstance

          public static QueryExplorerPatternRegistry getInstance()

    - #### addGeneratedPattern

          public void addGeneratedPattern(IQuerySpecification<?> specification)

    - #### isGenerated

          public boolean isGenerated(IQuerySpecification<?> query)

    - #### unregisterPattern

          public java.util.List<IQuerySpecification<?>> unregisterPattern(IQuerySpecification<?> specification)

      Unregisters the given pattern from the registry.
      Parameters:
        `specification` - the pattern instance to be unregistered

    - #### registerPatternModel

          public java.util.Set<IQuerySpecification<?>> registerPatternModel(org.eclipse.core.resources.IFile file,
                                                                            PatternModel patternModel)
                                                                     throws ViatraQueryException

      Registers the patterns within the given (parsed) pattern model.
      Parameters:
        `file` - the vql file instance
        `patternModel` - the parsed pattern model
      Returns:
        the list of patterns registered
      Throws:
        `ViatraQueryException`

    - #### addActivePattern

          public void addActivePattern(IQuerySpecification<?> p)

      Sets the given pattern as active ("checks on the Query Explorer").
      Parameters:
        `p` - the pattern instance

    - #### getRegisteredPatternsForFile

          public java.util.List<IQuerySpecification<?>> getRegisteredPatternsForFile(org.eclipse.core.resources.IFile file)

      Returns the (unmodifiable) list of registered patterns from the given file.
      Parameters:
        `file` - the vql file instance
      Returns:
        the list of patterns registered

    - #### isEmpty

          public boolean isEmpty()

      Returns true if there are no (generic) patterns registered, false otherwise.
      Returns:

    - #### unregisterPatternModel

          public java.util.List<IQuerySpecification<?>> unregisterPatternModel(org.eclipse.core.resources.IFile file)

      Unregisters the patterns within the given vql file and returns the list of those patterns that were currently active from the given file.
      Parameters:
        `file` - the vql file instance
      Returns:
        the list of removed patterns

    - #### removeActivePattern

          public void removeActivePattern(IQuerySpecification<?> p)

      Sets the given pattern as passive.
      Parameters:
        `p` - the pattern instance

    - #### removeActivePattern

          public void removeActivePattern(java.lang.String patternFqn)

    - #### getPatternByFqn

          public IQuerySpecification<?> getPatternByFqn(java.lang.String patternFqn)

      Returns the pattern associated with the given fully qualified name.
      Parameters:
        `patternFqn` - the fqn of the pattern
      Returns:
        the pattern instance

    - #### getActivePatterns

          public java.util.List<IQuerySpecification<?>> getActivePatterns()

      Returns the list of active patterns.
      Returns:
        the list of active patterns

    - #### isActive

          public boolean isActive(java.lang.String patternFqn)

      Returns true if the given pattern is currently active, false otherwise.
      Parameters:
        `patternFqn` - the fqn of the pattern
      Returns:
        true if the pattern is active, false otherwise

    - #### getPatternNames

          public java.util.Collection<java.lang.String> getPatternNames()

      Returns the names of the patterns registered in the registry.
      Returns:
        the list of names of the patterns

    - #### getGenericQuerySpecifications

          public java.util.Collection<IQuerySpecification<?>> getGenericQuerySpecifications()

      Returns the list of (generic) patterns registered in the registry.
      Returns:
        the list of (generic) patterns registered

    - #### getAllPatterns

          public java.util.List<IQuerySpecification<?>> getAllPatterns()

      Return a list of all known patterns.
      Returns:
        a union of getGeneratedPatterns and getGenericPatterns

    - #### getFiles

          public java.util.Collection<org.eclipse.core.resources.IFile> getFiles()

      Returns the list of vql files from which patterns are registered.
      Returns:
        the list of vql files

    - #### getFileForPattern

          public org.eclipse.core.resources.IFile getFileForPattern(IQuerySpecification<?> pattern)

      Returns the vql file instance that the given pattern can be found in.
      Parameters:
        `pattern` - the pattern instance
      Returns:
        the vql file

    - #### getQueryExplorerCheckedValue

          public static com.google.common.base.Optional<java.lang.Boolean> getQueryExplorerCheckedValue(IQuerySpecification<?> query)

      Returns an Optional that has value if the user declared "@QueryExplorer(checked=value)" on the pattern. If the attribute is not set, returns absent.
      Parameters:
        `query` -
      Returns:

    - #### getGeneratedQuerySpecifications

          public static com.google.common.collect.ImmutableList<IQuerySpecification<?>> getGeneratedQuerySpecifications()

      access the list of "generated" query specifications
      Returns: