Package org.eclipse.viatra.addon.querybasedfeatures.runtime

## Class QueryBasedFeatureHelper

- java.lang.Object
- - org.eclipse.viatra.addon.querybasedfeatures.runtime.QueryBasedFeatureHelper

-     public final class QueryBasedFeatureHelper
      extends java.lang.Object

  Utility class for instantiating query-based feature handlers (`IQueryBasedFeatureHandler`).

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected static QueryBasedFeature` | `createQueryBasedFeature​(org.eclipse.emf.ecore.EStructuralFeature feature, QueryBasedFeatureKind kind, boolean keepCache)` |
    `static IQueryBasedFeatureHandler` | `getQueryBasedFeatureHandler​(org.eclipse.emf.common.notify.Notifier notifier, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.String patternFQN, java.lang.String sourceParamName, java.lang.String targetParamName, QueryBasedFeatureKind kind, boolean keepCache)` | Returns the `IQueryBasedFeatureHandler` for the given `EStructuralFeature` in the given `Notifier`.
    `static IQueryBasedFeatureHandler` | `getQueryBasedFeatureHandler​(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.String patternFQN, java.lang.String sourceParamName, java.lang.String targetParamName, QueryBasedFeatureKind kind)` | Returns the `IQueryBasedFeatureHandler` for the given `EStructuralFeature` on the topmost `Notifier` reachable from the source.
    `static IQueryBasedFeatureHandler` | `getQueryBasedFeatureHandler​(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.String patternFQN, java.lang.String sourceParamName, java.lang.String targetParamName, QueryBasedFeatureKind kind, boolean keepCache, boolean useSourceAsNotifier)` | Returns the `IQueryBasedFeatureHandler` for the given `EStructuralFeature` on the source or the topmost `Notifier` reachable from the source.
    `static IQueryBasedFeatureHandler` | `getQueryBasedFeatureHandlerOnNotifier​(org.eclipse.emf.common.notify.Notifier notifier, org.eclipse.emf.ecore.EStructuralFeature feature, java.lang.String patternFQN, java.lang.String sourceParamName, java.lang.String targetParamName, QueryBasedFeatureKind kind)` | Returns the `IQueryBasedFeatureHandler` for the given `EStructuralFeature` in the given `Notifier`.
    `static org.eclipse.emf.common.notify.Notifier` | `prepareNotifierForSource​(org.eclipse.emf.ecore.EObject source)` | Decide what `Notifier` to use as the scope of the `ViatraQueryMatcher` underlying the created `IQueryBasedFeatureHandler`.

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

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

- - ### Method Detail

    - #### prepareNotifierForSource

          public static org.eclipse.emf.common.notify.Notifier prepareNotifierForSource​(org.eclipse.emf.ecore.EObject source)

      Decide what `Notifier` to use as the scope of the `ViatraQueryMatcher` underlying the created `IQueryBasedFeatureHandler`.

      Optimally, the `ResourceSet` is reachable and most other matchers will use it as well.

      Otherwise, the `Resource` is used if the model is not inside a resource set.

      If none of the above are reachable, the container hierarchy is traversed for a top element.

      Finally, the source itself is returned.

      Parameters:
        `source` - the source object that initializes the handler
      Returns:
        the topmost reachable Notifier from the source

    - #### getQueryBasedFeatureHandler

          public static IQueryBasedFeatureHandler getQueryBasedFeatureHandler​(org.eclipse.emf.common.notify.Notifier notifier,
                                                                              org.eclipse.emf.ecore.EStructuralFeature feature,
                                                                              java.lang.String patternFQN,
                                                                              java.lang.String sourceParamName,
                                                                              java.lang.String targetParamName,
                                                                              QueryBasedFeatureKind kind,
                                                                              boolean keepCache)

      Returns the `IQueryBasedFeatureHandler` for the given `EStructuralFeature` in the given `Notifier`. If the handler does not exist yet, it is also initialized, before being returned.

      The required matcher is initialized using the pattern fully qualified name passed as a parameter.

      Parameters:
        `notifier` - the exact notifier to use for the handler initialization
        `feature` - the feature that is managed by the handler
        `patternFQN` - the fully qualified name of the pattern used by the handler
        `sourceParamName` - the name of the parameter in the pattern that represents the source end of the feature
        `targetParamName` - the name of the parameter in the pattern that represents the target end of the feature
        `kind` - the `QueryBasedFeatureKind` that is used by the handler
        `keepCache` - specifies whether the handler uses an internal cache for feature values. Only possible with single and many reference kinds
      Returns:
        the query-based feature handler that manages the feature values

    - #### createQueryBasedFeature

          protected static QueryBasedFeature createQueryBasedFeature​(org.eclipse.emf.ecore.EStructuralFeature feature,
                                                                     QueryBasedFeatureKind kind,
                                                                     boolean keepCache)

    - #### getQueryBasedFeatureHandlerOnNotifier

          public static IQueryBasedFeatureHandler getQueryBasedFeatureHandlerOnNotifier​(org.eclipse.emf.common.notify.Notifier notifier,
                                                                                        org.eclipse.emf.ecore.EStructuralFeature feature,
                                                                                        java.lang.String patternFQN,
                                                                                        java.lang.String sourceParamName,
                                                                                        java.lang.String targetParamName,
                                                                                        QueryBasedFeatureKind kind)

      Returns the `IQueryBasedFeatureHandler` for the given `EStructuralFeature` in the given `Notifier`. If the handler does not exist yet, it is also initialized, before being returned.

      The required matcher is initialized using the pattern fully qualified name passed as a parameter.

      Calls `getQueryBasedFeatureHandler(Notifier, EStructuralFeature, String, String, String, QueryBasedFeatureKind, boolean)` with keepCache = true.

      Parameters:
        `notifier` - the exact notifier to use for the handler initialization
        `feature` - the feature that is managed by the handler
        `patternFQN` - the fully qualified name of the pattern used by the handler
        `sourceParamName` - the name of the parameter in the pattern that represents the source end of the feature
        `targetParamName` - the name of the parameter in the pattern that represents the target end of the feature
        `kind` - the `QueryBasedFeatureKind` that is used by the handler
      Returns:
        the query-based feature handler that manages the feature values

    - #### getQueryBasedFeatureHandler

          public static IQueryBasedFeatureHandler getQueryBasedFeatureHandler​(org.eclipse.emf.ecore.EObject source,
                                                                              org.eclipse.emf.ecore.EStructuralFeature feature,
                                                                              java.lang.String patternFQN,
                                                                              java.lang.String sourceParamName,
                                                                              java.lang.String targetParamName,
                                                                              QueryBasedFeatureKind kind,
                                                                              boolean keepCache,
                                                                              boolean useSourceAsNotifier)

      Returns the `IQueryBasedFeatureHandler` for the given `EStructuralFeature` on the source or the topmost `Notifier` reachable from the source. If the handler does not exist yet, it is also initialized, before being returned.

      The required matcher is initialized using the pattern fully qualified name passed as a parameter.

      Calls `getQueryBasedFeatureHandler(Notifier, EStructuralFeature, String, String, String, QueryBasedFeatureKind, boolean)`.

      Parameters:
        `source` - the source object used for the handler initialization (used for determining the notifier for the underlying matcher)
        `feature` - the feature that is managed by the handler
        `patternFQN` - the fully qualified name of the pattern used by the handler
        `sourceParamName` - the name of the parameter in the pattern that represents the source end of the feature
        `targetParamName` - the name of the parameter in the pattern that represents the target end of the feature
        `kind` - the `QueryBasedFeatureKind` that is used by the handler
        `keepCache` - specifies whether the handler uses an internal cache for feature values. Only possible with single and many reference kinds
        `useSourceAsNotifier` - if true, the source is used as the notifier for the matcher initialization
      Returns:
        the query-based feature handler that manages the feature values

    - #### getQueryBasedFeatureHandler

          public static IQueryBasedFeatureHandler getQueryBasedFeatureHandler​(org.eclipse.emf.ecore.EObject source,
                                                                              org.eclipse.emf.ecore.EStructuralFeature feature,
                                                                              java.lang.String patternFQN,
                                                                              java.lang.String sourceParamName,
                                                                              java.lang.String targetParamName,
                                                                              QueryBasedFeatureKind kind)

      Returns the `IQueryBasedFeatureHandler` for the given `EStructuralFeature` on the topmost `Notifier` reachable from the source. If the handler does not exist yet, it is also initialized, before being returned.

      The required matcher is initialized using the pattern fully qualified name passed as a parameter.

      Calls `getQueryBasedFeatureHandler(EObject, EStructuralFeature, String, String, String, QueryBasedFeatureKind, boolean, boolean)`.

      Parameters:
        `source` - the source object used for the handler initialization (used for determining the notifier for the underlying matcher)
        `feature` - the feature that is managed by the handler
        `patternFQN` - the fully qualified name of the pattern used by the handler
        `sourceParamName` - the name of the parameter in the pattern that represents the source end of the feature
        `targetParamName` - the name of the parameter in the pattern that represents the target end of the feature
        `kind` - the `QueryBasedFeatureKind` that is used by the handler
      Returns:
        the query-based feature handler that manages the feature values