Interface NavigationHelper


  • public interface NavigationHelper
    Using an index of the EMF model, this interface exposes useful query functionality, such as:
    • Getting all the (direct or descendant) instances of a given EClass
    • Inverse navigation along arbitrary EReference instances (heterogenous paths too)
    • Finding model elements by attribute value (i.e. inverse navigation along EAttribute)
    • Querying instances of given data types, or structural features.
    As queries are served from an index, results are always instantaneous.

    Such indices will be built on an EMF model rooted at an EObject, Resource or ResourceSet. The boundaries of the model are defined by the containment (sub)tree. The indices will be maintained incrementally on changes to the model; these updates can also be observed by registering listeners.

    One of the options is to build indices in wildcard mode, meaning that all EClasses, EDataTypes, EReferences and EAttributes are indexed. This is convenient, but comes at a high memory cost. To save memory, one can disable wildcard mode and manually register those EClasses, EDataTypes, EReferences and EAttributes that should be indexed.

    Another choice is whether to build indices in dynamic EMF mode, meaning that types are identified by the String IDs that are ultimately derived from the nsURI of the EPackage. Multiple types with the same ID are treated as the same. This is useful if dynamic EMF is used, where there can be multiple copies (instantiations) of the same EPackage, representing essentially the same metamodel. If one disables dynamic EMF mode, an error is logged if duplicate EPackages with the same nsURI are encountered.

    Note that none of the defined query methods return null upon empty result sets. All query methods return either a copy of the result sets (where EStructuralFeature.Setting is instantiated) or an unmodifiable collection of the result view.

    Instantiate using ViatraBaseFactory

    No Implement:
    This interface is not intended to be implemented by clients.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addBaseIndexChangeListener​(EMFBaseIndexChangeListener listener)
      Adds a coarse-grained listener that will be invoked after the NavigationHelper index or the underlying model is changed.
      void addDataTypeListener​(java.util.Collection<org.eclipse.emf.ecore.EDataType> types, DataTypeListener listener)
      The given listener will be notified from now on whenever instances the given EDataTypes are added to or removed from the model.
      void addFeatureListener​(java.util.Collection<? extends org.eclipse.emf.ecore.EStructuralFeature> features, FeatureListener listener)
      The given listener will be notified from now on whenever instances the given EStructuralFeatures are added to or removed from the model.
      boolean addIndexingErrorListener​(IEMFIndexingErrorListener listener)
      Adds a listener for internal errors in the index.
      void addInstanceListener​(java.util.Collection<org.eclipse.emf.ecore.EClass> classes, InstanceListener listener)
      The given listener will be notified from now on whenever instances the given EClasses (and any of their subtypes) are added to or removed from the model.
      boolean addLightweightEObjectObserver​(LightweightEObjectObserver observer, org.eclipse.emf.ecore.EObject observedObject)
      Register a lightweight observer that is notified if the value of any feature of the given EObject changes.
      void addRoot​(org.eclipse.emf.common.notify.Notifier emfRoot)
      Adds an additional EMF model root.
      void cheapMoveTo​(org.eclipse.emf.ecore.EObject element, org.eclipse.emf.ecore.EObject parent, org.eclipse.emf.ecore.EReference containmentFeature)
      Moves an EObject (along with its entire containment subtree) within the containment hierarchy of the EMF model.
      <T extends org.eclipse.emf.ecore.EObject>
      void
      cheapMoveTo​(T element, org.eclipse.emf.common.util.EList<T> targetContainmentReferenceList)
      Moves an EObject (along with its entire containment subtree) within the containment hierarchy of the EMF model.
      <V> V coalesceTraversals​(java.util.concurrent.Callable<V> callable)
      The given callback will be executed, and all model traversals and index registrations will be delayed until the execution is done.
      int countAllInstances​(org.eclipse.emf.ecore.EClass clazz)
      Get the total number of instances of the given EClass and all of its subclasses.
      int countDataTypeInstances​(org.eclipse.emf.ecore.EDataType dataType)  
      int countFeatures​(org.eclipse.emf.ecore.EStructuralFeature feature)  
      int countFeatureTargets​(org.eclipse.emf.ecore.EObject seedSource, org.eclipse.emf.ecore.EStructuralFeature feature)  
      void dispose()
      Call this method to dispose the NavigationHelper.
      void executeAfterTraversal​(java.lang.Runnable traversalCallback)
      Execute the given runnable after traversal.
      java.util.Set<org.eclipse.emf.ecore.EStructuralFeature.Setting> findByAttributeValue​(java.lang.Object value)
      For a given attribute value value, find each EAttribute and host EObject such that this attribute of the the host object takes the given value.
      java.util.Set<org.eclipse.emf.ecore.EStructuralFeature.Setting> findByAttributeValue​(java.lang.Object value, java.util.Collection<org.eclipse.emf.ecore.EAttribute> attributes)
      For given attributes and an attribute value value, find each host EObject such that any of these attributes of the the host object takes the given value.
      java.util.Set<org.eclipse.emf.ecore.EObject> findByAttributeValue​(java.lang.Object value, org.eclipse.emf.ecore.EAttribute attribute)
      Find all EObjects for which the given attribute takes the given value.
      java.util.Set<org.eclipse.emf.ecore.EObject> findByFeatureValue​(java.lang.Object value, org.eclipse.emf.ecore.EStructuralFeature feature)
      Find all source EObjects for which the given feature points to / takes the given value.
      java.util.Set<org.eclipse.emf.ecore.EClass> getAllCurrentClasses()
      Returns all EClasses that currently have direct instances cached by the index.
      java.util.Set<org.eclipse.emf.ecore.EObject> getAllInstances​(org.eclipse.emf.ecore.EClass clazz)
      Get the all EObject instances of the given EClass.
      java.util.Set<java.lang.Object> getDataTypeInstances​(org.eclipse.emf.ecore.EDataType type)
      Returns the set of instances for the given EDataType that can be found in the model.
      java.util.Set<org.eclipse.emf.ecore.EObject> getDirectInstances​(org.eclipse.emf.ecore.EClass clazz)
      Get the direct EObject instances of the given EClass.
      java.util.Set<java.lang.Object> getFeatureTargets​(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EStructuralFeature feature)
      Find all Objects that are the target of the EStructuralFeature feature from the given source EObject.
      java.util.Set<org.eclipse.emf.ecore.EObject> getHoldersOfFeature​(org.eclipse.emf.ecore.EStructuralFeature feature)
      Returns those host EObjects that have a non-null value for the given feature (at least one, in case of multi-valued references).
      IndexingLevel getIndexingLevel​(org.eclipse.emf.ecore.EClass type)  
      IndexingLevel getIndexingLevel​(org.eclipse.emf.ecore.EDataType type)  
      IndexingLevel getIndexingLevel​(org.eclipse.emf.ecore.EStructuralFeature feature)  
      java.util.Set<org.eclipse.emf.ecore.EStructuralFeature.Setting> getInverseReferences​(org.eclipse.emf.ecore.EObject target)
      For a given EObject target, find each EReference and source EObject such that this reference (list) of the the host object points to the given target object.
      java.util.Set<org.eclipse.emf.ecore.EStructuralFeature.Setting> getInverseReferences​(org.eclipse.emf.ecore.EObject target, java.util.Collection<org.eclipse.emf.ecore.EReference> references)
      For given references and an EObject target, find each source EObject such that any of these references of the the source object points to the given target object.
      java.util.Set<org.eclipse.emf.ecore.EObject> getInverseReferences​(org.eclipse.emf.ecore.EObject target, org.eclipse.emf.ecore.EReference reference)
      Find all source EObjects for which the given reference points to the given target object.
      java.util.Set<org.eclipse.emf.ecore.EObject> getReferenceValues​(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EReference reference)
      Find all EObjects that are the target of the EReference reference from the given source EObject.
      java.util.Set<java.lang.Object> getValuesOfFeature​(org.eclipse.emf.ecore.EStructuralFeature feature)
      Returns all non-null values that the given feature takes at least once for any EObject in the scope
      IndexingLevel getWildcardLevel()
      Returns the current IndexingLevel applied to all model elements.
      boolean isCoalescing()
      Examines whether execution is currently in the callable block of an invocation of {#link coalesceTraversals(Callable)}.
      boolean isFeatureInstance​(org.eclipse.emf.ecore.EObject source, java.lang.Object target, org.eclipse.emf.ecore.EStructuralFeature feature)
      Decides whether the given non-null source and target objects are connected via a specific, indexed EStructuralFeature instance.
      boolean isInDynamicEMFMode()
      Indicates whether indexing is performed in dynamic EMF mode, i.e.
      boolean isInstanceOfDatatype​(java.lang.Object value, org.eclipse.emf.ecore.EDataType type)
      Returns whether an object is an instance for the given EDataType that can be found in the current scope.
      boolean isInstanceOfScoped​(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EClass clazz)
      Checks whether the given EObject is an instance of the given EClass.
      boolean isInstanceOfUnscoped​(org.eclipse.emf.ecore.EObject object, org.eclipse.emf.ecore.EClass clazz)
      Checks whether the given EObject is an instance of the given EClass.
      boolean isInWildcardMode()
      Indicates whether indexing is performed in wildcard mode, where every aspect of the EMF model is automatically indexed.
      boolean isInWildcardMode​(IndexingLevel level)
      Indicates whether indexing is performed in wildcard mode for a selected indexing level
      void processAllFeatureInstances​(org.eclipse.emf.ecore.EStructuralFeature feature, IStructuralFeatureInstanceProcessor processor)
      Traverses all instances of a selected feature stored in the base index, and allows executing a custom function on it.
      void processAllInstances​(org.eclipse.emf.ecore.EClass type, IEClassifierProcessor.IEClassProcessor processor)
      Traverses all direct instances of a selected class stored in the base index, and allows executing a custom function on it.
      void processDataTypeInstances​(org.eclipse.emf.ecore.EDataType type, IEClassifierProcessor.IEDataTypeProcessor processor)
      Traverses all instances of a selected data type stored in the base index, and allows executing a custom function on it.
      void processDirectInstances​(org.eclipse.emf.ecore.EClass type, IEClassifierProcessor.IEClassProcessor processor)
      Traverses all direct instances of a selected class stored in the base index, and allows executing a custom function on it.
      void registerEClasses​(java.util.Set<org.eclipse.emf.ecore.EClass> classes, IndexingLevel level)
      Manually turns on indexing for the given classes (indexing of other classes are unaffected).
      void registerEDataTypes​(java.util.Set<org.eclipse.emf.ecore.EDataType> dataTypes, IndexingLevel level)
      Manually turns on indexing for the given data types (indexing of other features are unaffected).
      void registerEStructuralFeatures​(java.util.Set<? extends org.eclipse.emf.ecore.EStructuralFeature> features, IndexingLevel level)
      Manually turns on indexing for the given features (indexing of other features are unaffected).
      void registerObservedTypes​(java.util.Set<org.eclipse.emf.ecore.EClass> classes, java.util.Set<org.eclipse.emf.ecore.EDataType> dataTypes, java.util.Set<? extends org.eclipse.emf.ecore.EStructuralFeature> features, IndexingLevel level)
      Manually turns on indexing for the given types (indexing of others are unaffected).
      void removeBaseIndexChangeListener​(EMFBaseIndexChangeListener listener)
      Removes a registered listener.
      void removeDataTypeListener​(java.util.Collection<org.eclipse.emf.ecore.EDataType> types, DataTypeListener listener)
      Unregisters a data type listener for the given types.
      void removeFeatureListener​(java.util.Collection<? extends org.eclipse.emf.ecore.EStructuralFeature> features, FeatureListener listener)
      Unregisters a feature listener for the given features.
      boolean removeIndexingErrorListener​(IEMFIndexingErrorListener listener)
      Removes a listener for internal errors in the index.
      void removeInstanceListener​(java.util.Collection<org.eclipse.emf.ecore.EClass> classes, InstanceListener listener)
      Unregisters an instance listener for the given classes.
      boolean removeLightweightEObjectObserver​(LightweightEObjectObserver observer, org.eclipse.emf.ecore.EObject observedObject)
      Unregisters a lightweight observer for the given EObject.
      void resampleDerivedFeatures()
      Updates the value of indexed derived features that are not well-behaving.
      void setWildcardLevel​(IndexingLevel level)
      Starts wildcard indexing at the given level.
      java.lang.Object toCanonicalValueRepresentation​(java.lang.Object value)
      Returns the internal, canonicalized implementation of an attribute value.
      void unregisterEClasses​(java.util.Set<org.eclipse.emf.ecore.EClass> classes)
      Manually turns off indexing for the given classes (indexing of other classes are unaffected).
      void unregisterEDataTypes​(java.util.Set<org.eclipse.emf.ecore.EDataType> dataTypes)
      Manually turns off indexing for the given data types (indexing of other data types are unaffected).
      void unregisterEStructuralFeatures​(java.util.Set<? extends org.eclipse.emf.ecore.EStructuralFeature> features)
      Manually turns off indexing for the given features (indexing of other features are unaffected).
      void unregisterObservedTypes​(java.util.Set<org.eclipse.emf.ecore.EClass> classes, java.util.Set<org.eclipse.emf.ecore.EDataType> dataTypes, java.util.Set<? extends org.eclipse.emf.ecore.EStructuralFeature> features)
      Manually turns off indexing for the given types (indexing of others are unaffected).
    • Method Detail

      • isInWildcardMode

        boolean isInWildcardMode()
        Indicates whether indexing is performed in wildcard mode, where every aspect of the EMF model is automatically indexed.
        Returns:
        true if everything is indexed, false if manual registration of interesting EClassifiers and EStructuralFeatures is required.
      • isInWildcardMode

        boolean isInWildcardMode​(IndexingLevel level)
        Indicates whether indexing is performed in wildcard mode for a selected indexing level
        Returns:
        true if everything is indexed, false if manual registration of interesting EClassifiers and EStructuralFeatures is required.
        Since:
        1.5
      • getWildcardLevel

        IndexingLevel getWildcardLevel()
        Returns the current IndexingLevel applied to all model elements. For specific types it is possible to request a higher indexing levels, but cannot be lowered.
        Returns:
        the current level of index specified
        Since:
        1.4
      • setWildcardLevel

        void setWildcardLevel​(IndexingLevel level)
        Starts wildcard indexing at the given level. After this call, no registration is required for this IndexingLevel. a previously set wildcard level cannot be lowered, only extended.
        Since:
        1.4
      • isInDynamicEMFMode

        boolean isInDynamicEMFMode()
        Indicates whether indexing is performed in dynamic EMF mode, i.e. EPackage nsURI collisions are tolerated and EPackages with the same URI are automatically considered as equal.
        Returns:
        true if multiple EPackages with the same nsURI are treated as the same, false if an error is logged instead in this case.
      • findByAttributeValue

        java.util.Set<org.eclipse.emf.ecore.EStructuralFeature.Setting> findByAttributeValue​(java.lang.Object value)
        For a given attribute value value, find each EAttribute and host EObject such that this attribute of the the host object takes the given value. The method will return a set of EStructuralFeature.Settings, one for each such host object - EAttribute - value triplet.

        Precondition: Unset / null attribute values are not indexed, so value!=null

        Precondition: Will only find those EAttributes that have already been registered using #registerEStructuralFeatures(Set), unless running in wildcard mode (see isInWildcardMode()).

        Parameters:
        value - the value of the attribute
        Returns:
        a set of EStructuralFeature.Settings, one for each EObject and EAttribute that have the given value
        See Also:
        findByAttributeValue(Object)
      • findByAttributeValue

        java.util.Set<org.eclipse.emf.ecore.EStructuralFeature.Setting> findByAttributeValue​(java.lang.Object value,
                                                                                             java.util.Collection<org.eclipse.emf.ecore.EAttribute> attributes)
        For given attributes and an attribute value value, find each host EObject such that any of these attributes of the the host object takes the given value. The method will return a set of EStructuralFeature.Settings, one for each such host object - EAttribute - value triplet.

        Precondition: Unset / null attribute values are not indexed, so value!=null

        Precondition: Will only find those EAttributes that have already been registered using #registerEStructuralFeatures(Set), unless running in wildcard mode (see isInWildcardMode()).

        Parameters:
        value - the value of the attribute
        attributes - the collection of attributes that should take the given value
        Returns:
        a set of EStructuralFeature.Settings, one for each EObject and attribute that have the given value
      • findByAttributeValue

        java.util.Set<org.eclipse.emf.ecore.EObject> findByAttributeValue​(java.lang.Object value,
                                                                          org.eclipse.emf.ecore.EAttribute attribute)
        Find all EObjects for which the given attribute takes the given value.

        Precondition: Unset / null attribute values are not indexed, so value!=null

        Precondition: Results will be returned only if either (a) the EAttribute has already been registered using #registerEStructuralFeatures(Set), or (b) running in wildcard mode (see isInWildcardMode()).

        Parameters:
        value - the value of the attribute
        attribute - the EAttribute that should take the given value
        Returns:
        the set of EObjects for which the given attribute has the given value
      • getDataTypeInstances

        java.util.Set<java.lang.Object> getDataTypeInstances​(org.eclipse.emf.ecore.EDataType type)
        Returns the set of instances for the given EDataType that can be found in the model.

        Precondition: Results will be returned only if either (a) the EDataType has already been registered using #registerEDataTypes(Set), or (b) running in wildcard mode (see isInWildcardMode()).

        Parameters:
        type - the data type
        Returns:
        the set of all attribute values found in the model that are of the given data type
      • isInstanceOfDatatype

        boolean isInstanceOfDatatype​(java.lang.Object value,
                                     org.eclipse.emf.ecore.EDataType type)
        Returns whether an object is an instance for the given EDataType that can be found in the current scope.

        Precondition: Result will be true only if either (a) the EDataType has already been registered using #registerEDataTypes(Set), or (b) running in wildcard mode (see isInWildcardMode()).

        Parameters:
        value - a non-null value to decide whether it is available as an EDataType instance
        type - a non-null EDataType
        Returns:
        true, if a corresponding instance was found
        Since:
        1.7
      • getReferenceValues

        java.util.Set<org.eclipse.emf.ecore.EObject> getReferenceValues​(org.eclipse.emf.ecore.EObject source,
                                                                        org.eclipse.emf.ecore.EReference reference)
        Find all EObjects that are the target of the EReference reference from the given source EObject.

        Unset / null-valued references are not indexed, and will not be included in the results.

        Precondition: Results will be returned only if either (a) the reference has already been registered using #registerEStructuralFeatures(Set), or (b) running in wildcard mode (see isInWildcardMode()).

        Parameters:
        source - the host object
        reference - an EReference of the host object
        Returns:
        the set of EObjects that the given reference points to, from the given source object
      • getFeatureTargets

        java.util.Set<java.lang.Object> getFeatureTargets​(org.eclipse.emf.ecore.EObject source,
                                                          org.eclipse.emf.ecore.EStructuralFeature feature)
        Find all Objects that are the target of the EStructuralFeature feature from the given source EObject.

        Unset / null-valued features are not indexed, and will not be included in the results.

        Precondition: Results will be returned only if either (a) the feature has already been registered, or (b) running in wildcard mode (see isInWildcardMode()).

        Parameters:
        source - the host object
        feature - an EStructuralFeature of the host object
        Returns:
        the set of values that the given feature takes at the given source object
        See Also:
        getReferenceValues(EObject, EReference)
      • isFeatureInstance

        boolean isFeatureInstance​(org.eclipse.emf.ecore.EObject source,
                                  java.lang.Object target,
                                  org.eclipse.emf.ecore.EStructuralFeature feature)
        Decides whether the given non-null source and target objects are connected via a specific, indexed EStructuralFeature instance.

        Unset / null-valued features are not indexed, and will not be included in the results.

        Precondition: Result will be true only if either (a) the feature has already been registered, or (b) running in wildcard mode (see isInWildcardMode()).

        Since:
        1.7
      • getInverseReferences

        java.util.Set<org.eclipse.emf.ecore.EStructuralFeature.Setting> getInverseReferences​(org.eclipse.emf.ecore.EObject target)
        For a given EObject target, find each EReference and source EObject such that this reference (list) of the the host object points to the given target object. The method will return a set of EStructuralFeature.Settings, one for each such source object - EReference - target triplet.

        Precondition: Unset / null reference values are not indexed, so target!=null

        Precondition: Results will be returned only for those references that have already been registered using #registerEStructuralFeatures(Set), or all references if running in wildcard mode (see isInWildcardMode()).

        Parameters:
        target - the EObject pointed to by the references
        Returns:
        a set of EStructuralFeature.Settings, one for each source EObject and reference that point to the given target
      • getInverseReferences

        java.util.Set<org.eclipse.emf.ecore.EStructuralFeature.Setting> getInverseReferences​(org.eclipse.emf.ecore.EObject target,
                                                                                             java.util.Collection<org.eclipse.emf.ecore.EReference> references)
        For given references and an EObject target, find each source EObject such that any of these references of the the source object points to the given target object. The method will return a set of EStructuralFeature.Settings, one for each such source object - EReference - target triplet.

        Precondition: Unset / null reference values are not indexed, so target!=null

        Precondition: Will only find those EReferences that have already been registered using #registerEStructuralFeatures(Set), unless running in wildcard mode (see isInWildcardMode()).

        Parameters:
        target - the EObject pointed to by the references
        references - a set of EReferences pointing to the target
        Returns:
        a set of EStructuralFeature.Settings, one for each source EObject and reference that point to the given target
      • getInverseReferences

        java.util.Set<org.eclipse.emf.ecore.EObject> getInverseReferences​(org.eclipse.emf.ecore.EObject target,
                                                                          org.eclipse.emf.ecore.EReference reference)
        Find all source EObjects for which the given reference points to the given target object.

        Precondition: Unset / null reference values are not indexed, so target!=null

        Precondition: Results will be returned only if either (a) the reference has already been registered using #registerEStructuralFeatures(Set), or (b) running in wildcard mode (see isInWildcardMode()).

        Parameters:
        target - the EObject pointed to by the references
        reference - an EReference pointing to the target
        Returns:
        the collection of EObjects for which the given reference points to the given target object
      • getDirectInstances

        java.util.Set<org.eclipse.emf.ecore.EObject> getDirectInstances​(org.eclipse.emf.ecore.EClass clazz)
        Get the direct EObject instances of the given EClass. Instances of subclasses will be excluded.

        Precondition: Results will be returned only if either (a) the EClass (or any superclass) has already been registered using #registerEClasses(Set), or (b) running in wildcard mode (see isInWildcardMode()).

        Parameters:
        clazz - an EClass
        Returns:
        the collection of EObject direct instances of the given EClass (not of subclasses)
        See Also:
        getAllInstances(EClass)
      • getAllInstances

        java.util.Set<org.eclipse.emf.ecore.EObject> getAllInstances​(org.eclipse.emf.ecore.EClass clazz)
        Get the all EObject instances of the given EClass. This includes instances of subclasses.

        Precondition: Results will be returned only if either (a) the EClass (or any superclass) has already been registered using #registerEClasses(Set), or (b) running in wildcard mode (see isInWildcardMode()).

        Parameters:
        clazz - an EClass
        Returns:
        the collection of EObject instances of the given EClass and any of its subclasses
        See Also:
        getDirectInstances(EClass)
      • isInstanceOfUnscoped

        boolean isInstanceOfUnscoped​(org.eclipse.emf.ecore.EObject object,
                                     org.eclipse.emf.ecore.EClass clazz)
        Checks whether the given EObject is an instance of the given EClass. This includes instances of subclasses.

        Special note: this method does not check whether the object is indexed in the scope, and will return true for out-of-scope objects as well (as long as they are instances of the class).

        The given class does not have to be indexed.

        The difference between this method and EClassifier.isInstance(Object) is that in dynamic EMF mode, EPackage equivalence is taken into account.

        Since:
        1.6
      • isInstanceOfScoped

        boolean isInstanceOfScoped​(org.eclipse.emf.ecore.EObject object,
                                   org.eclipse.emf.ecore.EClass clazz)
        Checks whether the given EObject is an instance of the given EClass. This includes instances of subclasses.

        Special note: this method does check whether the object is indexed in the scope, and will return false for out-of-scope objects as well (as long as they are instances of the class).

        The given class does have to be indexed.

        Since:
        1.7
      • countAllInstances

        int countAllInstances​(org.eclipse.emf.ecore.EClass clazz)
        Get the total number of instances of the given EClass and all of its subclasses.
        Since:
        1.4
      • findByFeatureValue

        java.util.Set<org.eclipse.emf.ecore.EObject> findByFeatureValue​(java.lang.Object value,
                                                                        org.eclipse.emf.ecore.EStructuralFeature feature)
        Find all source EObjects for which the given feature points to / takes the given value.

        Precondition: Unset / null-valued features are not indexed, so value!=null

        Precondition: Results will be returned only if either (a) the feature has already been registered using #registerEStructuralFeatures(Set), or (b) running in wildcard mode (see isInWildcardMode()).

        Parameters:
        value - the value of the feature
        feature - the feature instance
        Returns:
        the collection of EObject instances
      • getHoldersOfFeature

        java.util.Set<org.eclipse.emf.ecore.EObject> getHoldersOfFeature​(org.eclipse.emf.ecore.EStructuralFeature feature)
        Returns those host EObjects that have a non-null value for the given feature (at least one, in case of multi-valued references).

        Unset / null-valued features are not indexed, and will not be included in the results.

        Precondition: Results will be returned only if either (a) the feature has already been registered using #registerEStructuralFeatures(Set), or (b) running in wildcard mode (see isInWildcardMode()).

        Parameters:
        feature - a structural feature
        Returns:
        the collection of EObjects that have some value for the given structural feature
      • getValuesOfFeature

        java.util.Set<java.lang.Object> getValuesOfFeature​(org.eclipse.emf.ecore.EStructuralFeature feature)
        Returns all non-null values that the given feature takes at least once for any EObject in the scope

        Unset / null-valued features are not indexed, and will not be included in the results.

        Precondition: Results will be returned only if either (a) the feature has already been registered using #registerEStructuralFeatures(Set), or (b) running in wildcard mode (see isInWildcardMode()).

        Parameters:
        feature - a structural feature
        Returns:
        the collection of values that the given structural feature takes
        Since:
        2.1
      • dispose

        void dispose()
        Call this method to dispose the NavigationHelper.

        After its disposal, the NavigationHelper will no longer listen to EMF change notifications, and it will be possible to GC it even if the model is retained in memory.

        Precondition:
        no listeners can be registered at all.
        Throws:
        java.lang.IllegalStateException - if there are any active listeners
      • addInstanceListener

        void addInstanceListener​(java.util.Collection<org.eclipse.emf.ecore.EClass> classes,
                                 InstanceListener listener)
        The given listener will be notified from now on whenever instances the given EClasses (and any of their subtypes) are added to or removed from the model.
        Important: Do not call this method from InstanceListener methods as it may cause a ConcurrentModificationException, if you want to add a listener at that point, wrap the call with executeAfterTraversal(Runnable).
        Parameters:
        classes - the collection of classes whose instances the listener should be notified of
        listener - the listener instance
      • removeInstanceListener

        void removeInstanceListener​(java.util.Collection<org.eclipse.emf.ecore.EClass> classes,
                                    InstanceListener listener)
        Unregisters an instance listener for the given classes.
        Important: Do not call this method from InstanceListener methods as it may cause a ConcurrentModificationException, if you want to remove a listener at that point, wrap the call with executeAfterTraversal(Runnable).
        Parameters:
        classes - the collection of classes
        listener - the listener instance
      • addDataTypeListener

        void addDataTypeListener​(java.util.Collection<org.eclipse.emf.ecore.EDataType> types,
                                 DataTypeListener listener)
        The given listener will be notified from now on whenever instances the given EDataTypes are added to or removed from the model.
        Important: Do not call this method from DataTypeListener methods as it may cause a ConcurrentModificationException, if you want to add a listener at that point, wrap the call with executeAfterTraversal(Runnable).
        Parameters:
        types - the collection of types associated to the listener
        listener - the listener instance
      • removeDataTypeListener

        void removeDataTypeListener​(java.util.Collection<org.eclipse.emf.ecore.EDataType> types,
                                    DataTypeListener listener)
        Unregisters a data type listener for the given types.
        Important: Do not call this method from DataTypeListener methods as it may cause a ConcurrentModificationException, if you want to remove a listener at that point, wrap the call with executeAfterTraversal(Runnable).
        Parameters:
        types - the collection of data types
        listener - the listener instance
      • addFeatureListener

        void addFeatureListener​(java.util.Collection<? extends org.eclipse.emf.ecore.EStructuralFeature> features,
                                FeatureListener listener)
        The given listener will be notified from now on whenever instances the given EStructuralFeatures are added to or removed from the model.
        Important: Do not call this method from FeatureListener methods as it may cause a ConcurrentModificationException, if you want to add a listener at that point, wrap the call with executeAfterTraversal(Runnable).
        Parameters:
        features - the collection of features associated to the listener
        listener - the listener instance
      • removeFeatureListener

        void removeFeatureListener​(java.util.Collection<? extends org.eclipse.emf.ecore.EStructuralFeature> features,
                                   FeatureListener listener)
        Unregisters a feature listener for the given features.
        Important: Do not call this method from FeatureListener methods as it may cause a ConcurrentModificationException, if you want to remove a listener at that point, wrap the call with executeAfterTraversal(Runnable).
        Parameters:
        listener - the listener instance
        features - the collection of features
      • addLightweightEObjectObserver

        boolean addLightweightEObjectObserver​(LightweightEObjectObserver observer,
                                              org.eclipse.emf.ecore.EObject observedObject)
        Register a lightweight observer that is notified if the value of any feature of the given EObject changes.
        Important: Do not call this method from LightweightEObjectObserver methods as it may cause a ConcurrentModificationException, if you want to add an observer at that point, wrap the call with executeAfterTraversal(Runnable).
        Parameters:
        observer - the listener instance
        observedObject - the observed EObject
        Returns:
        false if the observer was already attached to the object (call has no effect), true otherwise
      • removeLightweightEObjectObserver

        boolean removeLightweightEObjectObserver​(LightweightEObjectObserver observer,
                                                 org.eclipse.emf.ecore.EObject observedObject)
        Unregisters a lightweight observer for the given EObject.
        Important: Do not call this method from LightweightEObjectObserver methods as it may cause a ConcurrentModificationException, if you want to remove an observer at that point, wrap the call with executeAfterTraversal(Runnable).
        Parameters:
        observer - the listener instance
        observedObject - the observed EObject
        Returns:
        false if the observer has not been previously attached to the object (call has no effect), true otherwise
      • registerObservedTypes

        void registerObservedTypes​(java.util.Set<org.eclipse.emf.ecore.EClass> classes,
                                   java.util.Set<org.eclipse.emf.ecore.EDataType> dataTypes,
                                   java.util.Set<? extends org.eclipse.emf.ecore.EStructuralFeature> features,
                                   IndexingLevel level)
        Manually turns on indexing for the given types (indexing of others are unaffected). Note that registering new types will result in a single iteration through the whole attached model. Not usable in wildcard mode.
        Parameters:
        classes - the set of classes to observe (null okay)
        dataTypes - the set of data types to observe (null okay)
        features - the set of features to observe (null okay)
        Throws:
        java.lang.IllegalStateException - if in wildcard mode
        Since:
        1.4
      • unregisterObservedTypes

        void unregisterObservedTypes​(java.util.Set<org.eclipse.emf.ecore.EClass> classes,
                                     java.util.Set<org.eclipse.emf.ecore.EDataType> dataTypes,
                                     java.util.Set<? extends org.eclipse.emf.ecore.EStructuralFeature> features)
        Manually turns off indexing for the given types (indexing of others are unaffected). Note that if the unregistered types are re-registered later, the whole attached model needs to be visited again. Not usable in wildcard mode.
        Precondition:
        no listeners can be registered for the given types.
        Parameters:
        classes - the set of classes that will be ignored again from now on (null okay)
        dataTypes - the set of data types that will be ignored again from now on (null okay)
        features - the set of features that will be ignored again from now on (null okay)
        Throws:
        java.lang.IllegalStateException - if in wildcard mode, or if there are listeners registered for the given types
      • registerEStructuralFeatures

        void registerEStructuralFeatures​(java.util.Set<? extends org.eclipse.emf.ecore.EStructuralFeature> features,
                                         IndexingLevel level)
        Manually turns on indexing for the given features (indexing of other features are unaffected). Note that registering new features will result in a single iteration through the whole attached model. Not usable in wildcard mode.
        Parameters:
        features - the set of features to observe
        Throws:
        java.lang.IllegalStateException - if in wildcard mode
        Since:
        1.4
      • unregisterEStructuralFeatures

        void unregisterEStructuralFeatures​(java.util.Set<? extends org.eclipse.emf.ecore.EStructuralFeature> features)
        Manually turns off indexing for the given features (indexing of other features are unaffected). Note that if the unregistered features are re-registered later, the whole attached model needs to be visited again. Not usable in wildcard mode.
        Precondition:
        no listeners can be registered for the given features.
        Parameters:
        features - the set of features that will be ignored again from now on
        Throws:
        java.lang.IllegalStateException - if in wildcard mode, or if there are listeners registered for the given types
      • registerEClasses

        void registerEClasses​(java.util.Set<org.eclipse.emf.ecore.EClass> classes,
                              IndexingLevel level)
        Manually turns on indexing for the given classes (indexing of other classes are unaffected). Instances of subclasses will also be indexed. Note that registering new classes will result in a single iteration through the whole attached model. Not usable in wildcard mode.
        Parameters:
        classes - the set of classes to observe
        Throws:
        java.lang.IllegalStateException - if in wildcard mode
        Since:
        1.4
      • unregisterEClasses

        void unregisterEClasses​(java.util.Set<org.eclipse.emf.ecore.EClass> classes)
        Manually turns off indexing for the given classes (indexing of other classes are unaffected). Note that if the unregistered classes are re-registered later, the whole attached model needs to be visited again. Not usable in wildcard mode.
        Precondition:
        no listeners can be registered for the given classes.
        Parameters:
        classes - the set of classes that will be ignored again from now on
        Throws:
        java.lang.IllegalStateException - if in wildcard mode, or if there are listeners registered for the given types
      • registerEDataTypes

        void registerEDataTypes​(java.util.Set<org.eclipse.emf.ecore.EDataType> dataTypes,
                                IndexingLevel level)
        Manually turns on indexing for the given data types (indexing of other features are unaffected). Note that registering new data types will result in a single iteration through the whole attached model. Not usable in wildcard mode.
        Parameters:
        dataTypes - the set of data types to observe
        Throws:
        java.lang.IllegalStateException - if in wildcard mode
        Since:
        1.4
      • unregisterEDataTypes

        void unregisterEDataTypes​(java.util.Set<org.eclipse.emf.ecore.EDataType> dataTypes)
        Manually turns off indexing for the given data types (indexing of other data types are unaffected). Note that if the unregistered data types are re-registered later, the whole attached model needs to be visited again. Not usable in wildcard mode.
        Precondition:
        no listeners can be registered for the given datatypes.
        Parameters:
        dataTypes - the set of data types that will be ignored again from now on
        Throws:
        java.lang.IllegalStateException - if in wildcard mode, or if there are listeners registered for the given types
      • coalesceTraversals

        <V> V coalesceTraversals​(java.util.concurrent.Callable<V> callable)
                          throws java.lang.reflect.InvocationTargetException
        The given callback will be executed, and all model traversals and index registrations will be delayed until the execution is done. If there are any outstanding feature, class or datatype registrations, a single coalesced model traversal will initialize the caches and deliver the notifications.
        Parameters:
        callable -
        Throws:
        java.lang.reflect.InvocationTargetException
      • executeAfterTraversal

        void executeAfterTraversal​(java.lang.Runnable traversalCallback)
                            throws java.lang.reflect.InvocationTargetException
        Execute the given runnable after traversal. It is guaranteed that the runnable is executed as soon as the indexing is finished. The callback is executed only once, then is removed from the callback queue.
        Parameters:
        traversalCallback -
        Throws:
        java.lang.reflect.InvocationTargetException
        Since:
        1.4
      • isCoalescing

        boolean isCoalescing()
        Examines whether execution is currently in the callable block of an invocation of {#link coalesceTraversals(Callable)}.
      • addRoot

        void addRoot​(org.eclipse.emf.common.notify.Notifier emfRoot)
        Adds an additional EMF model root.
        Parameters:
        emfRoot -
        Throws:
        ViatraQueryRuntimeException
      • cheapMoveTo

        <T extends org.eclipse.emf.ecore.EObject> void cheapMoveTo​(T element,
                                                                   org.eclipse.emf.common.util.EList<T> targetContainmentReferenceList)
        Moves an EObject (along with its entire containment subtree) within the containment hierarchy of the EMF model. The object will be relocated from the original parent object to a different parent, or a different containment list of the same parent.

        When indexing is enabled, such a relocation is costly if performed through normal getters/setters, as the index for the entire subtree is pruned at the old location and reconstructed at the new one. This method provides a workaround to keep the operation cheap.

        This method is experimental. Re-entrancy not supported.

        Parameters:
        element - the eObject to be moved
        targetContainmentReferenceList - containment list of the new parent object into which the element has to be moved
      • cheapMoveTo

        void cheapMoveTo​(org.eclipse.emf.ecore.EObject element,
                         org.eclipse.emf.ecore.EObject parent,
                         org.eclipse.emf.ecore.EReference containmentFeature)
        Moves an EObject (along with its entire containment subtree) within the containment hierarchy of the EMF model. The object will be relocated from the original parent object to a different parent, or a different containment list of the same parent.

        When indexing is enabled, such a relocation is costly if performed through normal getters/setters, as the index for the entire subtree is pruned at the old location and reconstructed at the new one. This method provides a workaround to keep the operation cheap.

        This method is experimental. Re-entrancy not supported.

        Parameters:
        element - the eObject to be moved
        parent - the new parent object under which the element has to be moved
        containmentFeature - the kind of containment reference that should be established between the new parent and the element
      • processDataTypeInstances

        void processDataTypeInstances​(org.eclipse.emf.ecore.EDataType type,
                                      IEClassifierProcessor.IEDataTypeProcessor processor)
        Traverses all instances of a selected data type stored in the base index, and allows executing a custom function on it. There is no guaranteed order in which the processor will be called with the selected features.
        Parameters:
        type -
        processor -
        Since:
        0.8
      • processAllInstances

        void processAllInstances​(org.eclipse.emf.ecore.EClass type,
                                 IEClassifierProcessor.IEClassProcessor processor)
        Traverses all direct instances of a selected class stored in the base index, and allows executing a custom function on it. There is no guaranteed order in which the processor will be called with the selected features.
        Parameters:
        type -
        processor -
        Since:
        0.8
      • processDirectInstances

        void processDirectInstances​(org.eclipse.emf.ecore.EClass type,
                                    IEClassifierProcessor.IEClassProcessor processor)
        Traverses all direct instances of a selected class stored in the base index, and allows executing a custom function on it. There is no guaranteed order in which the processor will be called with the selected features.
        Parameters:
        type -
        processor -
        Since:
        0.8
      • processAllFeatureInstances

        void processAllFeatureInstances​(org.eclipse.emf.ecore.EStructuralFeature feature,
                                        IStructuralFeatureInstanceProcessor processor)
        Traverses all instances of a selected feature stored in the base index, and allows executing a custom function on it. There is no guaranteed order in which the processor will be called with the selected features.

        Precondition: Will only find those EStructuralFeatures that have already been registered using #registerEStructuralFeatures(Set), unless running in wildcard mode (see isInWildcardMode()).

        Since:
        1.7
      • getAllCurrentClasses

        java.util.Set<org.eclipse.emf.ecore.EClass> getAllCurrentClasses()
        Returns all EClasses that currently have direct instances cached by the index.
        • Supertypes will not be returned, unless they have direct instances in the model as well.
        • If not in wildcard mode, only registered EClasses and their subtypes will be considered.
        • Note for advanced users: if a type is represented by multiple EClass objects, one of them is chosen as representative and returned.
      • resampleDerivedFeatures

        void resampleDerivedFeatures()
        Updates the value of indexed derived features that are not well-behaving.
      • addIndexingErrorListener

        boolean addIndexingErrorListener​(IEMFIndexingErrorListener listener)
        Adds a listener for internal errors in the index. A listener can only be added once.
        Parameters:
        listener -
        Since:
        0.8
      • removeIndexingErrorListener

        boolean removeIndexingErrorListener​(IEMFIndexingErrorListener listener)
        Removes a listener for internal errors in the index.
        Parameters:
        listener -
        Since:
        0.8
      • toCanonicalValueRepresentation

        java.lang.Object toCanonicalValueRepresentation​(java.lang.Object value)
        Returns the internal, canonicalized implementation of an attribute value.

        Behaviour: when in dynamic EMF mode, substitutes enum literals with a canonical version of the enum literal. Otherwise, returns the input.

        The canonical enum literal will be guaranteed to be a valid EMF enum literal (Enumerator), and the best effort is made to ensure that it will be the same for all versions of the EEnum, including EEnumLiterals in different versions of ecore packages, as well as Java enums generated from them..

        Usage is not required when simply querying the indexed model through the NavigationHelper API, as both method inputs and the results returned are automatically canonicalized in dynamic EMF mode. Using this method is required only if the client wants to do querying/filtering on the results returned, and wants to know what to look for.

      • getIndexingLevel

        IndexingLevel getIndexingLevel​(org.eclipse.emf.ecore.EClass type)
        Since:
        1.4
      • getIndexingLevel

        IndexingLevel getIndexingLevel​(org.eclipse.emf.ecore.EDataType type)
        Since:
        1.4
      • getIndexingLevel

        IndexingLevel getIndexingLevel​(org.eclipse.emf.ecore.EStructuralFeature feature)
        Since:
        1.4
      • countDataTypeInstances

        int countDataTypeInstances​(org.eclipse.emf.ecore.EDataType dataType)
        Since:
        1.4
      • countFeatureTargets

        int countFeatureTargets​(org.eclipse.emf.ecore.EObject seedSource,
                                org.eclipse.emf.ecore.EStructuralFeature feature)
        Since:
        1.4
      • countFeatures

        int countFeatures​(org.eclipse.emf.ecore.EStructuralFeature feature)
        Since:
        1.4