org.eclipse.viatra.query.runtime.registry.view

## Class AbstractRegistryView

- java.lang.Object
- - org.eclipse.viatra.query.runtime.registry.view.AbstractRegistryView

- All Implemented Interfaces:
    IQuerySpecificationRegistryChangeListener, IRegistryView

      public abstract class AbstractRegistryView
      extends java.lang.Object
      implements IRegistryView

  An abstract `IRegistryView` implementation that stores the registry, the set of listeners added to the view and the FQN to entry map of the view itself. The only responsibility of subclasses is to decide whether an entry received as an addition or removal notification is relevant to the view.
  Since:
    1.3

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `allowDuplicateFQNs`
    `protected IMultiLookup<java.lang.String,IQuerySpecificationRegistryEntry>` | `fqnToEntryMap`
    `protected java.util.Set<IQuerySpecificationRegistryChangeListener>` | `listeners`
    `protected IQuerySpecificationRegistry` | `registry`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractRegistryView(IQuerySpecificationRegistry registry, boolean allowDuplicateFQNs)` Creates a new view instance for the given registry.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addViewListener(IQuerySpecificationRegistryChangeListener listener)` Adds a listener to the view that will be notified when an entry is added to or removed from the view.
    `void` | `entryAdded(IQuerySpecificationRegistryEntry entry)` Called when a new entry is added to the registry.
    `void` | `entryRemoved(IQuerySpecificationRegistryEntry entry)` Called when an existing entry is removed from the registry.
    `java.lang.Iterable<IQuerySpecificationRegistryEntry>` | `getEntries()`
    `java.util.Set<IQuerySpecificationRegistryEntry>` | `getEntries(java.lang.String fullyQualifiedName)`
    `java.util.Set<java.lang.String>` | `getQuerySpecificationFQNs()`
    `IQuerySpecificationRegistry` | `getRegistry()`
    `boolean` | `hasQuerySpecificationFQN(java.lang.String fullyQualifiedName)`
    `protected abstract boolean` | `isEntryRelevant(IQuerySpecificationRegistryEntry entry)` This method is called both when an addition or removal notification is received from the registry.
    `void` | `removeViewListener(IQuerySpecificationRegistryChangeListener listener)` Removes a listener that was previously added to the view.

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

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

- - ### Field Detail

    - #### registry

          protected final IQuerySpecificationRegistry registry

    - #### fqnToEntryMap

          protected final IMultiLookup<java.lang.String,IQuerySpecificationRegistryEntry> fqnToEntryMap

    - #### listeners

          protected final java.util.Set<IQuerySpecificationRegistryChangeListener> listeners

    - #### allowDuplicateFQNs

          protected final boolean allowDuplicateFQNs

  - ### Constructor Detail

    - #### AbstractRegistryView

          public AbstractRegistryView(IQuerySpecificationRegistry registry,
                                      boolean allowDuplicateFQNs)

      Creates a new view instance for the given registry. Note that views are created by the registry and the view update mechanisms are also set up by the registry.
      Parameters:
        `registry` -

  - ### Method Detail

    - #### isEntryRelevant

          protected abstract boolean isEntryRelevant(IQuerySpecificationRegistryEntry entry)

      This method is called both when an addition or removal notification is received from the registry. Subclasses can implement view filtering by returning false for those specifications that are not relevant for this view.
      Parameters:
        `entry` - that is added or removed in the registry
      Returns:
        true if the entry should be added to or removed from the view, false otherwise

    - #### getRegistry

          public IQuerySpecificationRegistry getRegistry()

      Specified by:
        `getRegistry` in interface `IRegistryView`
      Returns:
        the registry underlying the view

    - #### getEntries

          public java.lang.Iterable<IQuerySpecificationRegistryEntry> getEntries()

      Specified by:
        `getEntries` in interface `IRegistryView`
      Returns:
        an immutable copy of all entries found in the view

    - #### getQuerySpecificationFQNs

          public java.util.Set<java.lang.String> getQuerySpecificationFQNs()

      Specified by:
        `getQuerySpecificationFQNs` in interface `IRegistryView`
      Returns:
        the set of FQNs for the query specifications in the view

    - #### hasQuerySpecificationFQN

          public boolean hasQuerySpecificationFQN(java.lang.String fullyQualifiedName)

      Specified by:
        `hasQuerySpecificationFQN` in interface `IRegistryView`
      Parameters:
        `fullyQualifiedName` - that is looked up in the view
      Returns:
        true if the view contains an entry with given FQN, false otherwise

    - #### getEntries

          public java.util.Set<IQuerySpecificationRegistryEntry> getEntries(java.lang.String fullyQualifiedName)

      Specified by:
        `getEntries` in interface `IRegistryView`
      Parameters:
        `fullyQualifiedName` - of the entries that are requested
      Returns:
        the possible empty set of entries with the given FQN

    - #### addViewListener

          public void addViewListener(IQuerySpecificationRegistryChangeListener listener)

      Description copied from interface: `IRegistryView`
      Adds a listener to the view that will be notified when an entry is added to or removed from the view.
      Specified by:
        `addViewListener` in interface `IRegistryView`
      Parameters:
        `listener` - that is added

    - #### removeViewListener

          public void removeViewListener(IQuerySpecificationRegistryChangeListener listener)

      Description copied from interface: `IRegistryView`
      Removes a listener that was previously added to the view.
      Specified by:
        `removeViewListener` in interface `IRegistryView`
      Parameters:
        `listener` - that is removed

    - #### entryAdded

          public void entryAdded(IQuerySpecificationRegistryEntry entry)

      Description copied from interface: `IQuerySpecificationRegistryChangeListener`
      Called when a new entry is added to the registry.
      Specified by:
        `entryAdded` in interface `IQuerySpecificationRegistryChangeListener`
      Parameters:
        `entry` - that is added

    - #### entryRemoved

          public void entryRemoved(IQuerySpecificationRegistryEntry entry)

      Description copied from interface: `IQuerySpecificationRegistryChangeListener`
      Called when an existing entry is removed from the registry.
      Specified by:
        `entryRemoved` in interface `IQuerySpecificationRegistryChangeListener`
      Parameters:
        `entry` - that is removed