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 abstractIRegistryViewimplementation 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 Description protected booleanallowDuplicateFQNsprotected IMultiLookup<java.lang.String,IQuerySpecificationRegistryEntry>fqnToEntryMapprotected java.util.Set<IQuerySpecificationRegistryChangeListener>listenersprotected IQuerySpecificationRegistryregistry
-
Constructor Summary
Constructors Constructor 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 Description voidaddViewListener(IQuerySpecificationRegistryChangeListener listener)Adds a listener to the view that will be notified when an entry is added to or removed from the view.voidentryAdded(IQuerySpecificationRegistryEntry entry)Called when a new entry is added to the registry.voidentryRemoved(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()IQuerySpecificationRegistrygetRegistry()booleanhasQuerySpecificationFQN(java.lang.String fullyQualifiedName)protected abstract booleanisEntryRelevant(IQuerySpecificationRegistryEntry entry)This method is called both when an addition or removal notification is received from the registry.voidremoveViewListener(IQuerySpecificationRegistryChangeListener listener)Removes a listener that was previously added to the view.
-
-
-
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:
getRegistryin interfaceIRegistryView- Returns:
- the registry underlying the view
-
getEntries
public java.lang.Iterable<IQuerySpecificationRegistryEntry> getEntries()
- Specified by:
getEntriesin interfaceIRegistryView- Returns:
- an immutable copy of all entries found in the view
-
getQuerySpecificationFQNs
public java.util.Set<java.lang.String> getQuerySpecificationFQNs()
- Specified by:
getQuerySpecificationFQNsin interfaceIRegistryView- Returns:
- the set of FQNs for the query specifications in the view
-
hasQuerySpecificationFQN
public boolean hasQuerySpecificationFQN(java.lang.String fullyQualifiedName)
- Specified by:
hasQuerySpecificationFQNin interfaceIRegistryView- 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:
getEntriesin interfaceIRegistryView- 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:IRegistryViewAdds a listener to the view that will be notified when an entry is added to or removed from the view.- Specified by:
addViewListenerin interfaceIRegistryView- Parameters:
listener- that is added
-
removeViewListener
public void removeViewListener(IQuerySpecificationRegistryChangeListener listener)
Description copied from interface:IRegistryViewRemoves a listener that was previously added to the view.- Specified by:
removeViewListenerin interfaceIRegistryView- Parameters:
listener- that is removed
-
entryAdded
public void entryAdded(IQuerySpecificationRegistryEntry entry)
Description copied from interface:IQuerySpecificationRegistryChangeListenerCalled when a new entry is added to the registry.- Specified by:
entryAddedin interfaceIQuerySpecificationRegistryChangeListener- Parameters:
entry- that is added
-
entryRemoved
public void entryRemoved(IQuerySpecificationRegistryEntry entry)
Description copied from interface:IQuerySpecificationRegistryChangeListenerCalled when an existing entry is removed from the registry.- Specified by:
entryRemovedin interfaceIQuerySpecificationRegistryChangeListener- Parameters:
entry- that is removed
-
-