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)
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 theIQueryBasedFeatureHandler
for the givenEStructuralFeature
on the topmostNotifier
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 theIQueryBasedFeatureHandler
for the givenEStructuralFeature
on the source or the topmostNotifier
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)
static org.eclipse.emf.common.notify.Notifier
prepareNotifierForSource(org.eclipse.emf.ecore.EObject source)
Decide whatNotifier
to use as the scope of theViatraQueryMatcher
underlying the createdIQueryBasedFeatureHandler
.
-
-
-
Method Detail
-
prepareNotifierForSource
public static org.eclipse.emf.common.notify.Notifier prepareNotifierForSource(org.eclipse.emf.ecore.EObject source)
Decide whatNotifier
to use as the scope of theViatraQueryMatcher
underlying the createdIQueryBasedFeatureHandler
.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 theIQueryBasedFeatureHandler
for the givenEStructuralFeature
in the givenNotifier
. 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 initializationfeature
- the feature that is managed by the handlerpatternFQN
- the fully qualified name of the pattern used by the handlersourceParamName
- the name of the parameter in the pattern that represents the source end of the featuretargetParamName
- the name of the parameter in the pattern that represents the target end of the featurekind
- theQueryBasedFeatureKind
that is used by the handlerkeepCache
- 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 theIQueryBasedFeatureHandler
for the givenEStructuralFeature
in the givenNotifier
. 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 initializationfeature
- the feature that is managed by the handlerpatternFQN
- the fully qualified name of the pattern used by the handlersourceParamName
- the name of the parameter in the pattern that represents the source end of the featuretargetParamName
- the name of the parameter in the pattern that represents the target end of the featurekind
- theQueryBasedFeatureKind
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 theIQueryBasedFeatureHandler
for the givenEStructuralFeature
on the source or the topmostNotifier
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.
- 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 handlerpatternFQN
- the fully qualified name of the pattern used by the handlersourceParamName
- the name of the parameter in the pattern that represents the source end of the featuretargetParamName
- the name of the parameter in the pattern that represents the target end of the featurekind
- theQueryBasedFeatureKind
that is used by the handlerkeepCache
- specifies whether the handler uses an internal cache for feature values. Only possible with single and many reference kindsuseSourceAsNotifier
- 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 theIQueryBasedFeatureHandler
for the givenEStructuralFeature
on the topmostNotifier
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.
- 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 handlerpatternFQN
- the fully qualified name of the pattern used by the handlersourceParamName
- the name of the parameter in the pattern that represents the source end of the featuretargetParamName
- the name of the parameter in the pattern that represents the target end of the featurekind
- theQueryBasedFeatureKind
that is used by the handler- Returns:
- the query-based feature handler that manages the feature values
-
-