querySpecification() {
- return ActorGeneralization.instance();
- }
- }
-
- private ActorGeneralization() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ActorGeneralization instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected ActorGeneralization.Matcher instantiate(final ViatraQueryEngine engine) {
- return ActorGeneralization.Matcher.on(engine);
- }
-
- @Override
- public ActorGeneralization.Matcher instantiate() {
- return ActorGeneralization.Matcher.create();
- }
-
- @Override
- public ActorGeneralization.Match newEmptyMatch() {
- return ActorGeneralization.Match.newEmptyMatch();
- }
-
- @Override
- public ActorGeneralization.Match newMatch(final Object... parameters) {
- return ActorGeneralization.Match.newMatch((com.nomagic.uml2.ext.magicdraw.mdusecases.Actor) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdpowertypes.GeneralizationSet) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link ActorGeneralization} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link ActorGeneralization#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final ActorGeneralization INSTANCE = new ActorGeneralization();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final ActorGeneralization.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_actor = new PParameter("actor", "com.nomagic.uml2.ext.magicdraw.mdusecases.Actor", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Actor")), PParameterDirection.INOUT);
-
- private final PParameter parameter_generalActor = new PParameter("generalActor", "com.nomagic.uml2.ext.magicdraw.classes.mdpowertypes.GeneralizationSet", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "GeneralizationSet")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_actor, parameter_generalActor);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.actorGeneralization";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("actor","generalActor");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_actor = body.getOrCreateVariableByName("actor");
- PVariable var_generalActor = body.getOrCreateVariableByName("generalActor");
- new TypeConstraint(body, Tuples.flatTupleOf(var_actor), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Actor")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_generalActor), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "GeneralizationSet")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_actor, parameter_actor),
- new ExportedParameter(body, var_generalActor, parameter_generalActor)
- ));
- // Actor.generalization.generalizationSet(actor, generalActor)
- new TypeConstraint(body, Tuples.flatTupleOf(var_actor), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Actor")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_actor, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier", "generalization")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Generalization")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Generalization", "generalizationSet")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "GeneralizationSet")));
- new Equality(body, var__virtual_1_, var_generalActor);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/AllBenchMarkedQueries.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/AllBenchMarkedQueries.java
deleted file mode 100644
index 146a77a..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/AllBenchMarkedQueries.java
+++ /dev/null
@@ -1,634 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.AlphabeticalDependencies;
-import com.incquerylabs.magicdraw.benchmark.queries.BlocksOrRequirementsOrConstraints;
-import com.incquerylabs.magicdraw.benchmark.queries.CircularDependencies;
-import com.incquerylabs.magicdraw.benchmark.queries.LoopTransitionWithTriggerEffectEventNoGuard;
-import com.incquerylabs.magicdraw.benchmark.queries.TransitionPointingOutOfCompState;
-import com.incquerylabs.magicdraw.benchmark.queries.TransitiveSubstatesWithCheck3;
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * pattern allBenchMarkedQueries(param : NamedElement) {
- * find blocksOrRequirementsOrConstraints(param);
- * } or {
- * find transitiveSubstatesWithCheck3(param, _);
- * } or {
- * find alphabeticalDependencies(param, _);
- * } or {
- * find circularDependencies(param);
- * } or {
- * find loopTransitionWithTriggerEffectEventNoGuard(param, _, _, _, _);
- * } or {
- * find transitionPointingOutOfCompState(param, _, _);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class AllBenchMarkedQueries extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.allBenchMarkedQueries pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private NamedElement fParam;
-
- private static List parameterNames = makeImmutableList("param");
-
- private Match(final NamedElement pParam) {
- this.fParam = pParam;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "param": return this.fParam;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fParam;
- default: return null;
- }
- }
-
- public NamedElement getParam() {
- return this.fParam;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("param".equals(parameterName) ) {
- this.fParam = (NamedElement) newValue;
- return true;
- }
- return false;
- }
-
- public void setParam(final NamedElement pParam) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fParam = pParam;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.allBenchMarkedQueries";
- }
-
- @Override
- public List parameterNames() {
- return AllBenchMarkedQueries.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fParam};
- }
-
- @Override
- public AllBenchMarkedQueries.Match toImmutable() {
- return isMutable() ? newMatch(fParam) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"param\"=" + prettyPrintValue(fParam));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fParam);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof AllBenchMarkedQueries.Match)) {
- AllBenchMarkedQueries.Match other = (AllBenchMarkedQueries.Match) obj;
- return Objects.equals(fParam, other.fParam);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public AllBenchMarkedQueries specification() {
- return AllBenchMarkedQueries.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static AllBenchMarkedQueries.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pParam the fixed value of pattern parameter param, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static AllBenchMarkedQueries.Match newMutableMatch(final NamedElement pParam) {
- return new Mutable(pParam);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pParam the fixed value of pattern parameter param, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static AllBenchMarkedQueries.Match newMatch(final NamedElement pParam) {
- return new Immutable(pParam);
- }
-
- private static final class Mutable extends AllBenchMarkedQueries.Match {
- Mutable(final NamedElement pParam) {
- super(pParam);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends AllBenchMarkedQueries.Match {
- Immutable(final NamedElement pParam) {
- super(pParam);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.allBenchMarkedQueries pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * pattern allBenchMarkedQueries(param : NamedElement) {
- * find blocksOrRequirementsOrConstraints(param);
- * } or {
- * find transitiveSubstatesWithCheck3(param, _);
- * } or {
- * find alphabeticalDependencies(param, _);
- * } or {
- * find circularDependencies(param);
- * } or {
- * find loopTransitionWithTriggerEffectEventNoGuard(param, _, _, _, _);
- * } or {
- * find transitionPointingOutOfCompState(param, _, _);
- * }
- *
- *
- * @see Match
- * @see AllBenchMarkedQueries
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static AllBenchMarkedQueries.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static AllBenchMarkedQueries.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_PARAM = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AllBenchMarkedQueries.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pParam the fixed value of pattern parameter param, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final NamedElement pParam) {
- return rawStreamAllMatches(new Object[]{pParam}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pParam the fixed value of pattern parameter param, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final NamedElement pParam) {
- return rawStreamAllMatches(new Object[]{pParam});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pParam the fixed value of pattern parameter param, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final NamedElement pParam) {
- return rawGetOneArbitraryMatch(new Object[]{pParam});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pParam the fixed value of pattern parameter param, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final NamedElement pParam) {
- return rawHasMatch(new Object[]{pParam});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pParam the fixed value of pattern parameter param, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final NamedElement pParam) {
- return rawCountMatches(new Object[]{pParam});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pParam the fixed value of pattern parameter param, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final NamedElement pParam, final Consumer super AllBenchMarkedQueries.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pParam}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pParam the fixed value of pattern parameter param, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public AllBenchMarkedQueries.Match newMatch(final NamedElement pParam) {
- return AllBenchMarkedQueries.Match.newMatch(pParam);
- }
-
- /**
- * Retrieve the set of values that occur in matches for param.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfparam(final Object[] parameters) {
- return rawStreamAllValues(POSITION_PARAM, parameters).map(NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for param.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfparam() {
- return rawStreamAllValuesOfparam(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for param.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfparam() {
- return rawStreamAllValuesOfparam(emptyArray());
- }
-
- @Override
- protected AllBenchMarkedQueries.Match tupleToMatch(final Tuple t) {
- try {
- return AllBenchMarkedQueries.Match.newMatch((NamedElement) t.get(POSITION_PARAM));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected AllBenchMarkedQueries.Match arrayToMatch(final Object[] match) {
- try {
- return AllBenchMarkedQueries.Match.newMatch((NamedElement) match[POSITION_PARAM]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected AllBenchMarkedQueries.Match arrayToMatchMutable(final Object[] match) {
- try {
- return AllBenchMarkedQueries.Match.newMutableMatch((NamedElement) match[POSITION_PARAM]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return AllBenchMarkedQueries.instance();
- }
- }
-
- private AllBenchMarkedQueries() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static AllBenchMarkedQueries instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected AllBenchMarkedQueries.Matcher instantiate(final ViatraQueryEngine engine) {
- return AllBenchMarkedQueries.Matcher.on(engine);
- }
-
- @Override
- public AllBenchMarkedQueries.Matcher instantiate() {
- return AllBenchMarkedQueries.Matcher.create();
- }
-
- @Override
- public AllBenchMarkedQueries.Match newEmptyMatch() {
- return AllBenchMarkedQueries.Match.newEmptyMatch();
- }
-
- @Override
- public AllBenchMarkedQueries.Match newMatch(final Object... parameters) {
- return AllBenchMarkedQueries.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link AllBenchMarkedQueries} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link AllBenchMarkedQueries#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final AllBenchMarkedQueries INSTANCE = new AllBenchMarkedQueries();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final AllBenchMarkedQueries.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_param = new PParameter("param", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_param);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.allBenchMarkedQueries";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("param");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_param = body.getOrCreateVariableByName("param");
- new TypeConstraint(body, Tuples.flatTupleOf(var_param), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_param, parameter_param)
- ));
- // find blocksOrRequirementsOrConstraints(param)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_param), BlocksOrRequirementsOrConstraints.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- {
- PBody body = new PBody(this);
- PVariable var_param = body.getOrCreateVariableByName("param");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- new TypeConstraint(body, Tuples.flatTupleOf(var_param), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_param, parameter_param)
- ));
- // find transitiveSubstatesWithCheck3(param, _)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_param, var___0_), TransitiveSubstatesWithCheck3.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- {
- PBody body = new PBody(this);
- PVariable var_param = body.getOrCreateVariableByName("param");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- new TypeConstraint(body, Tuples.flatTupleOf(var_param), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_param, parameter_param)
- ));
- // find alphabeticalDependencies(param, _)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_param, var___0_), AlphabeticalDependencies.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- {
- PBody body = new PBody(this);
- PVariable var_param = body.getOrCreateVariableByName("param");
- new TypeConstraint(body, Tuples.flatTupleOf(var_param), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_param, parameter_param)
- ));
- // find circularDependencies(param)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_param), CircularDependencies.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- {
- PBody body = new PBody(this);
- PVariable var_param = body.getOrCreateVariableByName("param");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- PVariable var___1_ = body.getOrCreateVariableByName("_<1>");
- PVariable var___2_ = body.getOrCreateVariableByName("_<2>");
- PVariable var___3_ = body.getOrCreateVariableByName("_<3>");
- new TypeConstraint(body, Tuples.flatTupleOf(var_param), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_param, parameter_param)
- ));
- // find loopTransitionWithTriggerEffectEventNoGuard(param, _, _, _, _)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_param, var___0_, var___1_, var___2_, var___3_), LoopTransitionWithTriggerEffectEventNoGuard.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- {
- PBody body = new PBody(this);
- PVariable var_param = body.getOrCreateVariableByName("param");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- PVariable var___1_ = body.getOrCreateVariableByName("_<1>");
- new TypeConstraint(body, Tuples.flatTupleOf(var_param), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_param, parameter_param)
- ));
- // find transitionPointingOutOfCompState(param, _, _)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_param, var___0_, var___1_), TransitionPointingOutOfCompState.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/AlphabeticalDependencies.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/AlphabeticalDependencies.java
deleted file mode 100644
index f33a44d..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/AlphabeticalDependencies.java
+++ /dev/null
@@ -1,735 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.NamesOfDependencyEndpoints;
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
-import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Reusing the namesOfDependencyEndpoints pattern and filtering with a check.
- *
- * pattern alphabeticalDependencies(source : NamedElement, target : NamedElement) {
- * find namesOfDependencyEndpoints(source, sourceName, target, targetName);
- * check (sourceName {@literal <} targetName);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class AlphabeticalDependencies extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.alphabeticalDependencies pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private NamedElement fSource;
-
- private NamedElement fTarget;
-
- private static List parameterNames = makeImmutableList("source", "target");
-
- private Match(final NamedElement pSource, final NamedElement pTarget) {
- this.fSource = pSource;
- this.fTarget = pTarget;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "source": return this.fSource;
- case "target": return this.fTarget;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fSource;
- case 1: return this.fTarget;
- default: return null;
- }
- }
-
- public NamedElement getSource() {
- return this.fSource;
- }
-
- public NamedElement getTarget() {
- return this.fTarget;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("source".equals(parameterName) ) {
- this.fSource = (NamedElement) newValue;
- return true;
- }
- if ("target".equals(parameterName) ) {
- this.fTarget = (NamedElement) newValue;
- return true;
- }
- return false;
- }
-
- public void setSource(final NamedElement pSource) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fSource = pSource;
- }
-
- public void setTarget(final NamedElement pTarget) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fTarget = pTarget;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.alphabeticalDependencies";
- }
-
- @Override
- public List parameterNames() {
- return AlphabeticalDependencies.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fSource, fTarget};
- }
-
- @Override
- public AlphabeticalDependencies.Match toImmutable() {
- return isMutable() ? newMatch(fSource, fTarget) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"source\"=" + prettyPrintValue(fSource) + ", ");
- result.append("\"target\"=" + prettyPrintValue(fTarget));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fSource, fTarget);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof AlphabeticalDependencies.Match)) {
- AlphabeticalDependencies.Match other = (AlphabeticalDependencies.Match) obj;
- return Objects.equals(fSource, other.fSource) && Objects.equals(fTarget, other.fTarget);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public AlphabeticalDependencies specification() {
- return AlphabeticalDependencies.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static AlphabeticalDependencies.Match newEmptyMatch() {
- return new Mutable(null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static AlphabeticalDependencies.Match newMutableMatch(final NamedElement pSource, final NamedElement pTarget) {
- return new Mutable(pSource, pTarget);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static AlphabeticalDependencies.Match newMatch(final NamedElement pSource, final NamedElement pTarget) {
- return new Immutable(pSource, pTarget);
- }
-
- private static final class Mutable extends AlphabeticalDependencies.Match {
- Mutable(final NamedElement pSource, final NamedElement pTarget) {
- super(pSource, pTarget);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends AlphabeticalDependencies.Match {
- Immutable(final NamedElement pSource, final NamedElement pTarget) {
- super(pSource, pTarget);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.alphabeticalDependencies pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Reusing the namesOfDependencyEndpoints pattern and filtering with a check.
- *
- * pattern alphabeticalDependencies(source : NamedElement, target : NamedElement) {
- * find namesOfDependencyEndpoints(source, sourceName, target, targetName);
- * check (sourceName {@literal <} targetName);
- * }
- *
- *
- * @see Match
- * @see AlphabeticalDependencies
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static AlphabeticalDependencies.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static AlphabeticalDependencies.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_SOURCE = 0;
-
- private static final int POSITION_TARGET = 1;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AlphabeticalDependencies.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final NamedElement pSource, final NamedElement pTarget) {
- return rawStreamAllMatches(new Object[]{pSource, pTarget}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final NamedElement pSource, final NamedElement pTarget) {
- return rawStreamAllMatches(new Object[]{pSource, pTarget});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final NamedElement pSource, final NamedElement pTarget) {
- return rawGetOneArbitraryMatch(new Object[]{pSource, pTarget});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final NamedElement pSource, final NamedElement pTarget) {
- return rawHasMatch(new Object[]{pSource, pTarget});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final NamedElement pSource, final NamedElement pTarget) {
- return rawCountMatches(new Object[]{pSource, pTarget});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final NamedElement pSource, final NamedElement pTarget, final Consumer super AlphabeticalDependencies.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pSource, pTarget}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public AlphabeticalDependencies.Match newMatch(final NamedElement pSource, final NamedElement pTarget) {
- return AlphabeticalDependencies.Match.newMatch(pSource, pTarget);
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfsource(final Object[] parameters) {
- return rawStreamAllValues(POSITION_SOURCE, parameters).map(NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource() {
- return rawStreamAllValuesOfsource(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource() {
- return rawStreamAllValuesOfsource(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource(final AlphabeticalDependencies.Match partialMatch) {
- return rawStreamAllValuesOfsource(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource(final NamedElement pTarget) {
- return rawStreamAllValuesOfsource(new Object[]{null, pTarget});
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource(final AlphabeticalDependencies.Match partialMatch) {
- return rawStreamAllValuesOfsource(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource(final NamedElement pTarget) {
- return rawStreamAllValuesOfsource(new Object[]{null, pTarget}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOftarget(final Object[] parameters) {
- return rawStreamAllValues(POSITION_TARGET, parameters).map(NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget() {
- return rawStreamAllValuesOftarget(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget() {
- return rawStreamAllValuesOftarget(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget(final AlphabeticalDependencies.Match partialMatch) {
- return rawStreamAllValuesOftarget(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget(final NamedElement pSource) {
- return rawStreamAllValuesOftarget(new Object[]{pSource, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget(final AlphabeticalDependencies.Match partialMatch) {
- return rawStreamAllValuesOftarget(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget(final NamedElement pSource) {
- return rawStreamAllValuesOftarget(new Object[]{pSource, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected AlphabeticalDependencies.Match tupleToMatch(final Tuple t) {
- try {
- return AlphabeticalDependencies.Match.newMatch((NamedElement) t.get(POSITION_SOURCE), (NamedElement) t.get(POSITION_TARGET));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected AlphabeticalDependencies.Match arrayToMatch(final Object[] match) {
- try {
- return AlphabeticalDependencies.Match.newMatch((NamedElement) match[POSITION_SOURCE], (NamedElement) match[POSITION_TARGET]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected AlphabeticalDependencies.Match arrayToMatchMutable(final Object[] match) {
- try {
- return AlphabeticalDependencies.Match.newMutableMatch((NamedElement) match[POSITION_SOURCE], (NamedElement) match[POSITION_TARGET]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return AlphabeticalDependencies.instance();
- }
- }
-
- private AlphabeticalDependencies() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static AlphabeticalDependencies instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected AlphabeticalDependencies.Matcher instantiate(final ViatraQueryEngine engine) {
- return AlphabeticalDependencies.Matcher.on(engine);
- }
-
- @Override
- public AlphabeticalDependencies.Matcher instantiate() {
- return AlphabeticalDependencies.Matcher.create();
- }
-
- @Override
- public AlphabeticalDependencies.Match newEmptyMatch() {
- return AlphabeticalDependencies.Match.newEmptyMatch();
- }
-
- @Override
- public AlphabeticalDependencies.Match newMatch(final Object... parameters) {
- return AlphabeticalDependencies.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link AlphabeticalDependencies} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link AlphabeticalDependencies#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final AlphabeticalDependencies INSTANCE = new AlphabeticalDependencies();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final AlphabeticalDependencies.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_source = new PParameter("source", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")), PParameterDirection.INOUT);
-
- private final PParameter parameter_target = new PParameter("target", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_source, parameter_target);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.alphabeticalDependencies";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("source","target");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_source = body.getOrCreateVariableByName("source");
- PVariable var_target = body.getOrCreateVariableByName("target");
- PVariable var_sourceName = body.getOrCreateVariableByName("sourceName");
- PVariable var_targetName = body.getOrCreateVariableByName("targetName");
- new TypeConstraint(body, Tuples.flatTupleOf(var_source), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_source, parameter_source),
- new ExportedParameter(body, var_target, parameter_target)
- ));
- // find namesOfDependencyEndpoints(source, sourceName, target, targetName)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_source, var_sourceName, var_target, var_targetName), NamesOfDependencyEndpoints.instance().getInternalQueryRepresentation());
- // check (sourceName < targetName)
- new ExpressionEvaluation(body, new IExpressionEvaluator() {
-
- @Override
- public String getShortDescription() {
- return "Expression evaluation from pattern alphabeticalDependencies";
- }
-
- @Override
- public Iterable getInputParameterNames() {
- return Arrays.asList("sourceName", "targetName");}
-
- @Override
- public Object evaluateExpression(IValueProvider provider) throws Exception {
- String sourceName = (String) provider.getValue("sourceName");
- String targetName = (String) provider.getValue("targetName");
- return evaluateExpression_1_1(sourceName, targetName);
- }
- }, null);
- bodies.add(body);
- }
- return bodies;
- }
- }
-
- private static boolean evaluateExpression_1_1(final String sourceName, final String targetName) {
- boolean _lessThan = (sourceName.compareTo(targetName) < 0);
- return _lessThan;
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/AssociationClasses.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/AssociationClasses.java
deleted file mode 100644
index 0611908..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/AssociationClasses.java
+++ /dev/null
@@ -1,705 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/WarmUpQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.nomagic.uml2.ext.magicdraw.classes.mdassociationclasses.AssociationClass;
-import com.nomagic.uml2.ext.magicdraw.mdusecases.UseCase;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * pattern associationClasses(associationClass : AssociationClass, useCase : UseCase) {
- * AssociationClass.ownedUseCase(associationClass, useCase);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class AssociationClasses extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.associationClasses pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private AssociationClass fAssociationClass;
-
- private UseCase fUseCase;
-
- private static List parameterNames = makeImmutableList("associationClass", "useCase");
-
- private Match(final AssociationClass pAssociationClass, final UseCase pUseCase) {
- this.fAssociationClass = pAssociationClass;
- this.fUseCase = pUseCase;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "associationClass": return this.fAssociationClass;
- case "useCase": return this.fUseCase;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fAssociationClass;
- case 1: return this.fUseCase;
- default: return null;
- }
- }
-
- public AssociationClass getAssociationClass() {
- return this.fAssociationClass;
- }
-
- public UseCase getUseCase() {
- return this.fUseCase;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("associationClass".equals(parameterName) ) {
- this.fAssociationClass = (AssociationClass) newValue;
- return true;
- }
- if ("useCase".equals(parameterName) ) {
- this.fUseCase = (UseCase) newValue;
- return true;
- }
- return false;
- }
-
- public void setAssociationClass(final AssociationClass pAssociationClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fAssociationClass = pAssociationClass;
- }
-
- public void setUseCase(final UseCase pUseCase) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fUseCase = pUseCase;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.associationClasses";
- }
-
- @Override
- public List parameterNames() {
- return AssociationClasses.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fAssociationClass, fUseCase};
- }
-
- @Override
- public AssociationClasses.Match toImmutable() {
- return isMutable() ? newMatch(fAssociationClass, fUseCase) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"associationClass\"=" + prettyPrintValue(fAssociationClass) + ", ");
- result.append("\"useCase\"=" + prettyPrintValue(fUseCase));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fAssociationClass, fUseCase);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof AssociationClasses.Match)) {
- AssociationClasses.Match other = (AssociationClasses.Match) obj;
- return Objects.equals(fAssociationClass, other.fAssociationClass) && Objects.equals(fUseCase, other.fUseCase);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public AssociationClasses specification() {
- return AssociationClasses.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static AssociationClasses.Match newEmptyMatch() {
- return new Mutable(null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pAssociationClass the fixed value of pattern parameter associationClass, or null if not bound.
- * @param pUseCase the fixed value of pattern parameter useCase, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static AssociationClasses.Match newMutableMatch(final AssociationClass pAssociationClass, final UseCase pUseCase) {
- return new Mutable(pAssociationClass, pUseCase);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pAssociationClass the fixed value of pattern parameter associationClass, or null if not bound.
- * @param pUseCase the fixed value of pattern parameter useCase, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static AssociationClasses.Match newMatch(final AssociationClass pAssociationClass, final UseCase pUseCase) {
- return new Immutable(pAssociationClass, pUseCase);
- }
-
- private static final class Mutable extends AssociationClasses.Match {
- Mutable(final AssociationClass pAssociationClass, final UseCase pUseCase) {
- super(pAssociationClass, pUseCase);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends AssociationClasses.Match {
- Immutable(final AssociationClass pAssociationClass, final UseCase pUseCase) {
- super(pAssociationClass, pUseCase);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.associationClasses pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * pattern associationClasses(associationClass : AssociationClass, useCase : UseCase) {
- * AssociationClass.ownedUseCase(associationClass, useCase);
- * }
- *
- *
- * @see Match
- * @see AssociationClasses
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static AssociationClasses.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static AssociationClasses.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_ASSOCIATIONCLASS = 0;
-
- private static final int POSITION_USECASE = 1;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AssociationClasses.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pAssociationClass the fixed value of pattern parameter associationClass, or null if not bound.
- * @param pUseCase the fixed value of pattern parameter useCase, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final AssociationClass pAssociationClass, final UseCase pUseCase) {
- return rawStreamAllMatches(new Object[]{pAssociationClass, pUseCase}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pAssociationClass the fixed value of pattern parameter associationClass, or null if not bound.
- * @param pUseCase the fixed value of pattern parameter useCase, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final AssociationClass pAssociationClass, final UseCase pUseCase) {
- return rawStreamAllMatches(new Object[]{pAssociationClass, pUseCase});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pAssociationClass the fixed value of pattern parameter associationClass, or null if not bound.
- * @param pUseCase the fixed value of pattern parameter useCase, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final AssociationClass pAssociationClass, final UseCase pUseCase) {
- return rawGetOneArbitraryMatch(new Object[]{pAssociationClass, pUseCase});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pAssociationClass the fixed value of pattern parameter associationClass, or null if not bound.
- * @param pUseCase the fixed value of pattern parameter useCase, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final AssociationClass pAssociationClass, final UseCase pUseCase) {
- return rawHasMatch(new Object[]{pAssociationClass, pUseCase});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pAssociationClass the fixed value of pattern parameter associationClass, or null if not bound.
- * @param pUseCase the fixed value of pattern parameter useCase, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final AssociationClass pAssociationClass, final UseCase pUseCase) {
- return rawCountMatches(new Object[]{pAssociationClass, pUseCase});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pAssociationClass the fixed value of pattern parameter associationClass, or null if not bound.
- * @param pUseCase the fixed value of pattern parameter useCase, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final AssociationClass pAssociationClass, final UseCase pUseCase, final Consumer super AssociationClasses.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pAssociationClass, pUseCase}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pAssociationClass the fixed value of pattern parameter associationClass, or null if not bound.
- * @param pUseCase the fixed value of pattern parameter useCase, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public AssociationClasses.Match newMatch(final AssociationClass pAssociationClass, final UseCase pUseCase) {
- return AssociationClasses.Match.newMatch(pAssociationClass, pUseCase);
- }
-
- /**
- * Retrieve the set of values that occur in matches for associationClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfassociationClass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_ASSOCIATIONCLASS, parameters).map(AssociationClass.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for associationClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfassociationClass() {
- return rawStreamAllValuesOfassociationClass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for associationClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfassociationClass() {
- return rawStreamAllValuesOfassociationClass(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for associationClass.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfassociationClass(final AssociationClasses.Match partialMatch) {
- return rawStreamAllValuesOfassociationClass(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for associationClass.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfassociationClass(final UseCase pUseCase) {
- return rawStreamAllValuesOfassociationClass(new Object[]{null, pUseCase});
- }
-
- /**
- * Retrieve the set of values that occur in matches for associationClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfassociationClass(final AssociationClasses.Match partialMatch) {
- return rawStreamAllValuesOfassociationClass(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for associationClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfassociationClass(final UseCase pUseCase) {
- return rawStreamAllValuesOfassociationClass(new Object[]{null, pUseCase}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for useCase.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfuseCase(final Object[] parameters) {
- return rawStreamAllValues(POSITION_USECASE, parameters).map(UseCase.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for useCase.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfuseCase() {
- return rawStreamAllValuesOfuseCase(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for useCase.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfuseCase() {
- return rawStreamAllValuesOfuseCase(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for useCase.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfuseCase(final AssociationClasses.Match partialMatch) {
- return rawStreamAllValuesOfuseCase(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for useCase.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfuseCase(final AssociationClass pAssociationClass) {
- return rawStreamAllValuesOfuseCase(new Object[]{pAssociationClass, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for useCase.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfuseCase(final AssociationClasses.Match partialMatch) {
- return rawStreamAllValuesOfuseCase(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for useCase.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfuseCase(final AssociationClass pAssociationClass) {
- return rawStreamAllValuesOfuseCase(new Object[]{pAssociationClass, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected AssociationClasses.Match tupleToMatch(final Tuple t) {
- try {
- return AssociationClasses.Match.newMatch((AssociationClass) t.get(POSITION_ASSOCIATIONCLASS), (UseCase) t.get(POSITION_USECASE));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected AssociationClasses.Match arrayToMatch(final Object[] match) {
- try {
- return AssociationClasses.Match.newMatch((AssociationClass) match[POSITION_ASSOCIATIONCLASS], (UseCase) match[POSITION_USECASE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected AssociationClasses.Match arrayToMatchMutable(final Object[] match) {
- try {
- return AssociationClasses.Match.newMutableMatch((AssociationClass) match[POSITION_ASSOCIATIONCLASS], (UseCase) match[POSITION_USECASE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return AssociationClasses.instance();
- }
- }
-
- private AssociationClasses() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static AssociationClasses instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected AssociationClasses.Matcher instantiate(final ViatraQueryEngine engine) {
- return AssociationClasses.Matcher.on(engine);
- }
-
- @Override
- public AssociationClasses.Matcher instantiate() {
- return AssociationClasses.Matcher.create();
- }
-
- @Override
- public AssociationClasses.Match newEmptyMatch() {
- return AssociationClasses.Match.newEmptyMatch();
- }
-
- @Override
- public AssociationClasses.Match newMatch(final Object... parameters) {
- return AssociationClasses.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdassociationclasses.AssociationClass) parameters[0], (com.nomagic.uml2.ext.magicdraw.mdusecases.UseCase) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link AssociationClasses} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link AssociationClasses#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final AssociationClasses INSTANCE = new AssociationClasses();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final AssociationClasses.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_associationClass = new PParameter("associationClass", "com.nomagic.uml2.ext.magicdraw.classes.mdassociationclasses.AssociationClass", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "AssociationClass")), PParameterDirection.INOUT);
-
- private final PParameter parameter_useCase = new PParameter("useCase", "com.nomagic.uml2.ext.magicdraw.mdusecases.UseCase", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "UseCase")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_associationClass, parameter_useCase);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.associationClasses";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("associationClass","useCase");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_associationClass = body.getOrCreateVariableByName("associationClass");
- PVariable var_useCase = body.getOrCreateVariableByName("useCase");
- new TypeConstraint(body, Tuples.flatTupleOf(var_associationClass), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "AssociationClass")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_useCase), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "UseCase")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_associationClass, parameter_associationClass),
- new ExportedParameter(body, var_useCase, parameter_useCase)
- ));
- // AssociationClass.ownedUseCase(associationClass, useCase)
- new TypeConstraint(body, Tuples.flatTupleOf(var_associationClass), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "AssociationClass")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_associationClass, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier", "ownedUseCase")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "UseCase")));
- new Equality(body, var__virtual_0_, var_useCase);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Blocks.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Blocks.java
deleted file mode 100644
index df0c55b..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Blocks.java
+++ /dev/null
@@ -1,564 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Querying all instances of an EClass that have a short "reference chain".
- *
- * pattern blocks(class : Class) {
- * Class.appliedStereotypeInstance.classifier.name(class, "Block");
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class Blocks extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.blocks pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class fClass;
-
- private static List parameterNames = makeImmutableList("class");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- this.fClass = pClass;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "class": return this.fClass;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fClass;
- default: return null;
- }
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getValueOfClass() {
- return this.fClass;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("class".equals(parameterName) ) {
- this.fClass = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- return false;
- }
-
- public void setClass(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass = pClass;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.blocks";
- }
-
- @Override
- public List parameterNames() {
- return Blocks.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass};
- }
-
- @Override
- public Blocks.Match toImmutable() {
- return isMutable() ? newMatch(fClass) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof Blocks.Match)) {
- Blocks.Match other = (Blocks.Match) obj;
- return Objects.equals(fClass, other.fClass);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public Blocks specification() {
- return Blocks.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static Blocks.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static Blocks.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Mutable(pClass);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static Blocks.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Immutable(pClass);
- }
-
- private static final class Mutable extends Blocks.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends Blocks.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.blocks pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Querying all instances of an EClass that have a short "reference chain".
- *
- * pattern blocks(class : Class) {
- * Class.appliedStereotypeInstance.classifier.name(class, "Block");
- * }
- *
- *
- * @see Match
- * @see Blocks
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static Blocks.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static Blocks.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_CLASS = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Blocks.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawGetOneArbitraryMatch(new Object[]{pClass});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawHasMatch(new Object[]{pClass});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawCountMatches(new Object[]{pClass});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Consumer super Blocks.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public Blocks.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return Blocks.Match.newMatch(pClass);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfclass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_CLASS, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray());
- }
-
- @Override
- protected Blocks.Match tupleToMatch(final Tuple t) {
- try {
- return Blocks.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_CLASS));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected Blocks.Match arrayToMatch(final Object[] match) {
- try {
- return Blocks.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected Blocks.Match arrayToMatchMutable(final Object[] match) {
- try {
- return Blocks.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return Blocks.instance();
- }
- }
-
- private Blocks() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static Blocks instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected Blocks.Matcher instantiate(final ViatraQueryEngine engine) {
- return Blocks.Matcher.on(engine);
- }
-
- @Override
- public Blocks.Matcher instantiate() {
- return Blocks.Matcher.create();
- }
-
- @Override
- public Blocks.Match newEmptyMatch() {
- return Blocks.Match.newEmptyMatch();
- }
-
- @Override
- public Blocks.Match newMatch(final Object... parameters) {
- return Blocks.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link Blocks} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link Blocks#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final Blocks INSTANCE = new Blocks();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final Blocks.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_class = new PParameter("class", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.blocks";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_class = body.getOrCreateVariableByName("class");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class)
- ));
- // Class.appliedStereotypeInstance.classifier.name(class, "Block")
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new ConstantValue(body, var__virtual_0_, "Block");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Element", "appliedStereotypeInstance")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "InstanceSpecification")));
- PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "InstanceSpecification", "classifier")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement", "name")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "String")));
- new Equality(body, var__virtual_3_, var__virtual_0_);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/BlocksOrRequirements.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/BlocksOrRequirements.java
deleted file mode 100644
index 5083e1e..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/BlocksOrRequirements.java
+++ /dev/null
@@ -1,565 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.Blocks;
-import com.incquerylabs.magicdraw.benchmark.queries.Requirements;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Disjunction of blocks and requirements.
- *
- * pattern blocksOrRequirements(class : Class) {
- * find blocks(class);
- * } or {
- * find requirements(class);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class BlocksOrRequirements extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.blocksOrRequirements pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class fClass;
-
- private static List parameterNames = makeImmutableList("class");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- this.fClass = pClass;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "class": return this.fClass;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fClass;
- default: return null;
- }
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getValueOfClass() {
- return this.fClass;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("class".equals(parameterName) ) {
- this.fClass = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- return false;
- }
-
- public void setClass(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass = pClass;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.blocksOrRequirements";
- }
-
- @Override
- public List parameterNames() {
- return BlocksOrRequirements.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass};
- }
-
- @Override
- public BlocksOrRequirements.Match toImmutable() {
- return isMutable() ? newMatch(fClass) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof BlocksOrRequirements.Match)) {
- BlocksOrRequirements.Match other = (BlocksOrRequirements.Match) obj;
- return Objects.equals(fClass, other.fClass);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public BlocksOrRequirements specification() {
- return BlocksOrRequirements.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static BlocksOrRequirements.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static BlocksOrRequirements.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Mutable(pClass);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static BlocksOrRequirements.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Immutable(pClass);
- }
-
- private static final class Mutable extends BlocksOrRequirements.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends BlocksOrRequirements.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.blocksOrRequirements pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Disjunction of blocks and requirements.
- *
- * pattern blocksOrRequirements(class : Class) {
- * find blocks(class);
- * } or {
- * find requirements(class);
- * }
- *
- *
- * @see Match
- * @see BlocksOrRequirements
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static BlocksOrRequirements.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static BlocksOrRequirements.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_CLASS = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(BlocksOrRequirements.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawGetOneArbitraryMatch(new Object[]{pClass});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawHasMatch(new Object[]{pClass});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawCountMatches(new Object[]{pClass});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Consumer super BlocksOrRequirements.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public BlocksOrRequirements.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return BlocksOrRequirements.Match.newMatch(pClass);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfclass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_CLASS, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray());
- }
-
- @Override
- protected BlocksOrRequirements.Match tupleToMatch(final Tuple t) {
- try {
- return BlocksOrRequirements.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_CLASS));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected BlocksOrRequirements.Match arrayToMatch(final Object[] match) {
- try {
- return BlocksOrRequirements.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected BlocksOrRequirements.Match arrayToMatchMutable(final Object[] match) {
- try {
- return BlocksOrRequirements.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return BlocksOrRequirements.instance();
- }
- }
-
- private BlocksOrRequirements() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static BlocksOrRequirements instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected BlocksOrRequirements.Matcher instantiate(final ViatraQueryEngine engine) {
- return BlocksOrRequirements.Matcher.on(engine);
- }
-
- @Override
- public BlocksOrRequirements.Matcher instantiate() {
- return BlocksOrRequirements.Matcher.create();
- }
-
- @Override
- public BlocksOrRequirements.Match newEmptyMatch() {
- return BlocksOrRequirements.Match.newEmptyMatch();
- }
-
- @Override
- public BlocksOrRequirements.Match newMatch(final Object... parameters) {
- return BlocksOrRequirements.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link BlocksOrRequirements} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link BlocksOrRequirements#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final BlocksOrRequirements INSTANCE = new BlocksOrRequirements();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final BlocksOrRequirements.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_class = new PParameter("class", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.blocksOrRequirements";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_class = body.getOrCreateVariableByName("class");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class)
- ));
- // find blocks(class)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_class), Blocks.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- {
- PBody body = new PBody(this);
- PVariable var_class = body.getOrCreateVariableByName("class");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class)
- ));
- // find requirements(class)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_class), Requirements.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/BlocksOrRequirementsOrConstraints.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/BlocksOrRequirementsOrConstraints.java
deleted file mode 100644
index 2d6f435..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/BlocksOrRequirementsOrConstraints.java
+++ /dev/null
@@ -1,577 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.BlocksOrRequirements;
-import com.incquerylabs.magicdraw.benchmark.queries.Dependencies;
-import com.incquerylabs.magicdraw.benchmark.queries.internal.ConstraintBlocks;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Disjunction reusing the blocksOrRequirements and constraintBlocks patterns and the negation of dependencies.
- *
- * pattern blocksOrRequirementsOrConstraints(class : Class) {
- * find blocksOrRequirements(class);
- * } or {
- * find constraintBlocks(class);
- * neg find dependencies(class, _);
- * neg find dependencies(_, class);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class BlocksOrRequirementsOrConstraints extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.blocksOrRequirementsOrConstraints pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class fClass;
-
- private static List parameterNames = makeImmutableList("class");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- this.fClass = pClass;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "class": return this.fClass;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fClass;
- default: return null;
- }
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getValueOfClass() {
- return this.fClass;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("class".equals(parameterName) ) {
- this.fClass = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- return false;
- }
-
- public void setClass(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass = pClass;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.blocksOrRequirementsOrConstraints";
- }
-
- @Override
- public List parameterNames() {
- return BlocksOrRequirementsOrConstraints.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass};
- }
-
- @Override
- public BlocksOrRequirementsOrConstraints.Match toImmutable() {
- return isMutable() ? newMatch(fClass) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof BlocksOrRequirementsOrConstraints.Match)) {
- BlocksOrRequirementsOrConstraints.Match other = (BlocksOrRequirementsOrConstraints.Match) obj;
- return Objects.equals(fClass, other.fClass);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public BlocksOrRequirementsOrConstraints specification() {
- return BlocksOrRequirementsOrConstraints.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static BlocksOrRequirementsOrConstraints.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static BlocksOrRequirementsOrConstraints.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Mutable(pClass);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static BlocksOrRequirementsOrConstraints.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Immutable(pClass);
- }
-
- private static final class Mutable extends BlocksOrRequirementsOrConstraints.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends BlocksOrRequirementsOrConstraints.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.blocksOrRequirementsOrConstraints pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Disjunction reusing the blocksOrRequirements and constraintBlocks patterns and the negation of dependencies.
- *
- * pattern blocksOrRequirementsOrConstraints(class : Class) {
- * find blocksOrRequirements(class);
- * } or {
- * find constraintBlocks(class);
- * neg find dependencies(class, _);
- * neg find dependencies(_, class);
- * }
- *
- *
- * @see Match
- * @see BlocksOrRequirementsOrConstraints
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static BlocksOrRequirementsOrConstraints.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static BlocksOrRequirementsOrConstraints.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_CLASS = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(BlocksOrRequirementsOrConstraints.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawGetOneArbitraryMatch(new Object[]{pClass});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawHasMatch(new Object[]{pClass});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawCountMatches(new Object[]{pClass});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Consumer super BlocksOrRequirementsOrConstraints.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public BlocksOrRequirementsOrConstraints.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return BlocksOrRequirementsOrConstraints.Match.newMatch(pClass);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfclass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_CLASS, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray());
- }
-
- @Override
- protected BlocksOrRequirementsOrConstraints.Match tupleToMatch(final Tuple t) {
- try {
- return BlocksOrRequirementsOrConstraints.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_CLASS));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected BlocksOrRequirementsOrConstraints.Match arrayToMatch(final Object[] match) {
- try {
- return BlocksOrRequirementsOrConstraints.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected BlocksOrRequirementsOrConstraints.Match arrayToMatchMutable(final Object[] match) {
- try {
- return BlocksOrRequirementsOrConstraints.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return BlocksOrRequirementsOrConstraints.instance();
- }
- }
-
- private BlocksOrRequirementsOrConstraints() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static BlocksOrRequirementsOrConstraints instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected BlocksOrRequirementsOrConstraints.Matcher instantiate(final ViatraQueryEngine engine) {
- return BlocksOrRequirementsOrConstraints.Matcher.on(engine);
- }
-
- @Override
- public BlocksOrRequirementsOrConstraints.Matcher instantiate() {
- return BlocksOrRequirementsOrConstraints.Matcher.create();
- }
-
- @Override
- public BlocksOrRequirementsOrConstraints.Match newEmptyMatch() {
- return BlocksOrRequirementsOrConstraints.Match.newEmptyMatch();
- }
-
- @Override
- public BlocksOrRequirementsOrConstraints.Match newMatch(final Object... parameters) {
- return BlocksOrRequirementsOrConstraints.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link BlocksOrRequirementsOrConstraints} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link BlocksOrRequirementsOrConstraints#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final BlocksOrRequirementsOrConstraints INSTANCE = new BlocksOrRequirementsOrConstraints();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final BlocksOrRequirementsOrConstraints.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_class = new PParameter("class", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.blocksOrRequirementsOrConstraints";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_class = body.getOrCreateVariableByName("class");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class)
- ));
- // find blocksOrRequirements(class)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_class), BlocksOrRequirements.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- {
- PBody body = new PBody(this);
- PVariable var_class = body.getOrCreateVariableByName("class");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- PVariable var___1_ = body.getOrCreateVariableByName("_<1>");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class)
- ));
- // find constraintBlocks(class)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_class), ConstraintBlocks.instance().getInternalQueryRepresentation());
- // neg find dependencies(class, _)
- new NegativePatternCall(body, Tuples.flatTupleOf(var_class, var___0_), Dependencies.instance().getInternalQueryRepresentation());
- // neg find dependencies(_, class)
- new NegativePatternCall(body, Tuples.flatTupleOf(var___1_, var_class), Dependencies.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/CircularDependencies.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/CircularDependencies.java
deleted file mode 100644
index fcefebe..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/CircularDependencies.java
+++ /dev/null
@@ -1,550 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.DependencyChains;
-import com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.BinaryTransitiveClosure;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Pattern responsible for detecting circular dependency chains.
- *
- * pattern circularDependencies(dependency : Dependency) {
- * find dependencyChains+(dependency, dependency);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class CircularDependencies extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.circularDependencies pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private Dependency fDependency;
-
- private static List parameterNames = makeImmutableList("dependency");
-
- private Match(final Dependency pDependency) {
- this.fDependency = pDependency;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "dependency": return this.fDependency;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fDependency;
- default: return null;
- }
- }
-
- public Dependency getDependency() {
- return this.fDependency;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("dependency".equals(parameterName) ) {
- this.fDependency = (Dependency) newValue;
- return true;
- }
- return false;
- }
-
- public void setDependency(final Dependency pDependency) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fDependency = pDependency;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.circularDependencies";
- }
-
- @Override
- public List parameterNames() {
- return CircularDependencies.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fDependency};
- }
-
- @Override
- public CircularDependencies.Match toImmutable() {
- return isMutable() ? newMatch(fDependency) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"dependency\"=" + prettyPrintValue(fDependency));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fDependency);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof CircularDependencies.Match)) {
- CircularDependencies.Match other = (CircularDependencies.Match) obj;
- return Objects.equals(fDependency, other.fDependency);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public CircularDependencies specification() {
- return CircularDependencies.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static CircularDependencies.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pDependency the fixed value of pattern parameter dependency, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static CircularDependencies.Match newMutableMatch(final Dependency pDependency) {
- return new Mutable(pDependency);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pDependency the fixed value of pattern parameter dependency, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static CircularDependencies.Match newMatch(final Dependency pDependency) {
- return new Immutable(pDependency);
- }
-
- private static final class Mutable extends CircularDependencies.Match {
- Mutable(final Dependency pDependency) {
- super(pDependency);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends CircularDependencies.Match {
- Immutable(final Dependency pDependency) {
- super(pDependency);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.circularDependencies pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Pattern responsible for detecting circular dependency chains.
- *
- * pattern circularDependencies(dependency : Dependency) {
- * find dependencyChains+(dependency, dependency);
- * }
- *
- *
- * @see Match
- * @see CircularDependencies
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static CircularDependencies.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static CircularDependencies.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_DEPENDENCY = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CircularDependencies.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pDependency the fixed value of pattern parameter dependency, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final Dependency pDependency) {
- return rawStreamAllMatches(new Object[]{pDependency}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pDependency the fixed value of pattern parameter dependency, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final Dependency pDependency) {
- return rawStreamAllMatches(new Object[]{pDependency});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pDependency the fixed value of pattern parameter dependency, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final Dependency pDependency) {
- return rawGetOneArbitraryMatch(new Object[]{pDependency});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pDependency the fixed value of pattern parameter dependency, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final Dependency pDependency) {
- return rawHasMatch(new Object[]{pDependency});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pDependency the fixed value of pattern parameter dependency, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final Dependency pDependency) {
- return rawCountMatches(new Object[]{pDependency});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pDependency the fixed value of pattern parameter dependency, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final Dependency pDependency, final Consumer super CircularDependencies.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pDependency}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pDependency the fixed value of pattern parameter dependency, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public CircularDependencies.Match newMatch(final Dependency pDependency) {
- return CircularDependencies.Match.newMatch(pDependency);
- }
-
- /**
- * Retrieve the set of values that occur in matches for dependency.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfdependency(final Object[] parameters) {
- return rawStreamAllValues(POSITION_DEPENDENCY, parameters).map(Dependency.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for dependency.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfdependency() {
- return rawStreamAllValuesOfdependency(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for dependency.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfdependency() {
- return rawStreamAllValuesOfdependency(emptyArray());
- }
-
- @Override
- protected CircularDependencies.Match tupleToMatch(final Tuple t) {
- try {
- return CircularDependencies.Match.newMatch((Dependency) t.get(POSITION_DEPENDENCY));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected CircularDependencies.Match arrayToMatch(final Object[] match) {
- try {
- return CircularDependencies.Match.newMatch((Dependency) match[POSITION_DEPENDENCY]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected CircularDependencies.Match arrayToMatchMutable(final Object[] match) {
- try {
- return CircularDependencies.Match.newMutableMatch((Dependency) match[POSITION_DEPENDENCY]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return CircularDependencies.instance();
- }
- }
-
- private CircularDependencies() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static CircularDependencies instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected CircularDependencies.Matcher instantiate(final ViatraQueryEngine engine) {
- return CircularDependencies.Matcher.on(engine);
- }
-
- @Override
- public CircularDependencies.Matcher instantiate() {
- return CircularDependencies.Matcher.create();
- }
-
- @Override
- public CircularDependencies.Match newEmptyMatch() {
- return CircularDependencies.Match.newEmptyMatch();
- }
-
- @Override
- public CircularDependencies.Match newMatch(final Object... parameters) {
- return CircularDependencies.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link CircularDependencies} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link CircularDependencies#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final CircularDependencies INSTANCE = new CircularDependencies();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final CircularDependencies.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_dependency = new PParameter("dependency", "com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_dependency);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.circularDependencies";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("dependency");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_dependency = body.getOrCreateVariableByName("dependency");
- new TypeConstraint(body, Tuples.flatTupleOf(var_dependency), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_dependency, parameter_dependency)
- ));
- // find dependencyChains+(dependency, dependency)
- new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_dependency, var_dependency), DependencyChains.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Classes.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Classes.java
deleted file mode 100644
index f3afc1a..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Classes.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Querying all instances of an EClass.
- *
- * pattern classes(class : Class) {
- * Class(class);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class Classes extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.classes pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class fClass;
-
- private static List parameterNames = makeImmutableList("class");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- this.fClass = pClass;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "class": return this.fClass;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fClass;
- default: return null;
- }
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getValueOfClass() {
- return this.fClass;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("class".equals(parameterName) ) {
- this.fClass = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- return false;
- }
-
- public void setClass(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass = pClass;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.classes";
- }
-
- @Override
- public List parameterNames() {
- return Classes.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass};
- }
-
- @Override
- public Classes.Match toImmutable() {
- return isMutable() ? newMatch(fClass) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof Classes.Match)) {
- Classes.Match other = (Classes.Match) obj;
- return Objects.equals(fClass, other.fClass);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public Classes specification() {
- return Classes.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static Classes.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static Classes.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Mutable(pClass);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static Classes.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Immutable(pClass);
- }
-
- private static final class Mutable extends Classes.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends Classes.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.classes pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Querying all instances of an EClass.
- *
- * pattern classes(class : Class) {
- * Class(class);
- * }
- *
- *
- * @see Match
- * @see Classes
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static Classes.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static Classes.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_CLASS = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Classes.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawGetOneArbitraryMatch(new Object[]{pClass});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawHasMatch(new Object[]{pClass});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawCountMatches(new Object[]{pClass});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Consumer super Classes.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public Classes.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return Classes.Match.newMatch(pClass);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfclass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_CLASS, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray());
- }
-
- @Override
- protected Classes.Match tupleToMatch(final Tuple t) {
- try {
- return Classes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_CLASS));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected Classes.Match arrayToMatch(final Object[] match) {
- try {
- return Classes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected Classes.Match arrayToMatchMutable(final Object[] match) {
- try {
- return Classes.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return Classes.instance();
- }
- }
-
- private Classes() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static Classes instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected Classes.Matcher instantiate(final ViatraQueryEngine engine) {
- return Classes.Matcher.on(engine);
- }
-
- @Override
- public Classes.Matcher instantiate() {
- return Classes.Matcher.create();
- }
-
- @Override
- public Classes.Match newEmptyMatch() {
- return Classes.Match.newEmptyMatch();
- }
-
- @Override
- public Classes.Match newMatch(final Object... parameters) {
- return Classes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link Classes} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link Classes#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final Classes INSTANCE = new Classes();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final Classes.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_class = new PParameter("class", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.classes";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_class = body.getOrCreateVariableByName("class");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class)
- ));
- // Class(class)
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/ComplexNameOfElements.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/ComplexNameOfElements.java
deleted file mode 100644
index 3ae7e85..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/ComplexNameOfElements.java
+++ /dev/null
@@ -1,750 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
-import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-import org.eclipse.xtext.xbase.lib.StringExtensions;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Reusing namedElement and eval the names.
- *
- * pattern complexNameOfElements(element : NamedElement, complexName : java ^java.lang.String) {
- * find namedElement(element, name);
- * complexName == eval(name.toFirstUpper + ". "+ name.toFirstLower + "." + name.toUpperCase + "." + name.toLowerCase + "." + name.length);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class ComplexNameOfElements extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.complexNameOfElements pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private NamedElement fElement;
-
- private String fComplexName;
-
- private static List parameterNames = makeImmutableList("element", "complexName");
-
- private Match(final NamedElement pElement, final String pComplexName) {
- this.fElement = pElement;
- this.fComplexName = pComplexName;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "element": return this.fElement;
- case "complexName": return this.fComplexName;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fElement;
- case 1: return this.fComplexName;
- default: return null;
- }
- }
-
- public NamedElement getElement() {
- return this.fElement;
- }
-
- public String getComplexName() {
- return this.fComplexName;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("element".equals(parameterName) ) {
- this.fElement = (NamedElement) newValue;
- return true;
- }
- if ("complexName".equals(parameterName) ) {
- this.fComplexName = (String) newValue;
- return true;
- }
- return false;
- }
-
- public void setElement(final NamedElement pElement) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fElement = pElement;
- }
-
- public void setComplexName(final String pComplexName) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fComplexName = pComplexName;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.complexNameOfElements";
- }
-
- @Override
- public List parameterNames() {
- return ComplexNameOfElements.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fElement, fComplexName};
- }
-
- @Override
- public ComplexNameOfElements.Match toImmutable() {
- return isMutable() ? newMatch(fElement, fComplexName) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"element\"=" + prettyPrintValue(fElement) + ", ");
- result.append("\"complexName\"=" + prettyPrintValue(fComplexName));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fElement, fComplexName);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof ComplexNameOfElements.Match)) {
- ComplexNameOfElements.Match other = (ComplexNameOfElements.Match) obj;
- return Objects.equals(fElement, other.fElement) && Objects.equals(fComplexName, other.fComplexName);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public ComplexNameOfElements specification() {
- return ComplexNameOfElements.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static ComplexNameOfElements.Match newEmptyMatch() {
- return new Mutable(null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pComplexName the fixed value of pattern parameter complexName, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static ComplexNameOfElements.Match newMutableMatch(final NamedElement pElement, final String pComplexName) {
- return new Mutable(pElement, pComplexName);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pComplexName the fixed value of pattern parameter complexName, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static ComplexNameOfElements.Match newMatch(final NamedElement pElement, final String pComplexName) {
- return new Immutable(pElement, pComplexName);
- }
-
- private static final class Mutable extends ComplexNameOfElements.Match {
- Mutable(final NamedElement pElement, final String pComplexName) {
- super(pElement, pComplexName);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends ComplexNameOfElements.Match {
- Immutable(final NamedElement pElement, final String pComplexName) {
- super(pElement, pComplexName);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.complexNameOfElements pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Reusing namedElement and eval the names.
- *
- * pattern complexNameOfElements(element : NamedElement, complexName : java ^java.lang.String) {
- * find namedElement(element, name);
- * complexName == eval(name.toFirstUpper + ". "+ name.toFirstLower + "." + name.toUpperCase + "." + name.toLowerCase + "." + name.length);
- * }
- *
- *
- * @see Match
- * @see ComplexNameOfElements
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static ComplexNameOfElements.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static ComplexNameOfElements.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_ELEMENT = 0;
-
- private static final int POSITION_COMPLEXNAME = 1;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ComplexNameOfElements.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pComplexName the fixed value of pattern parameter complexName, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final NamedElement pElement, final String pComplexName) {
- return rawStreamAllMatches(new Object[]{pElement, pComplexName}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pComplexName the fixed value of pattern parameter complexName, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final NamedElement pElement, final String pComplexName) {
- return rawStreamAllMatches(new Object[]{pElement, pComplexName});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pComplexName the fixed value of pattern parameter complexName, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final NamedElement pElement, final String pComplexName) {
- return rawGetOneArbitraryMatch(new Object[]{pElement, pComplexName});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pComplexName the fixed value of pattern parameter complexName, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final NamedElement pElement, final String pComplexName) {
- return rawHasMatch(new Object[]{pElement, pComplexName});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pComplexName the fixed value of pattern parameter complexName, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final NamedElement pElement, final String pComplexName) {
- return rawCountMatches(new Object[]{pElement, pComplexName});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pComplexName the fixed value of pattern parameter complexName, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final NamedElement pElement, final String pComplexName, final Consumer super ComplexNameOfElements.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pElement, pComplexName}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pComplexName the fixed value of pattern parameter complexName, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public ComplexNameOfElements.Match newMatch(final NamedElement pElement, final String pComplexName) {
- return ComplexNameOfElements.Match.newMatch(pElement, pComplexName);
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfelement(final Object[] parameters) {
- return rawStreamAllValues(POSITION_ELEMENT, parameters).map(NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelement() {
- return rawStreamAllValuesOfelement(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfelement() {
- return rawStreamAllValuesOfelement(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfelement(final ComplexNameOfElements.Match partialMatch) {
- return rawStreamAllValuesOfelement(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfelement(final String pComplexName) {
- return rawStreamAllValuesOfelement(new Object[]{null, pComplexName});
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelement(final ComplexNameOfElements.Match partialMatch) {
- return rawStreamAllValuesOfelement(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelement(final String pComplexName) {
- return rawStreamAllValuesOfelement(new Object[]{null, pComplexName}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for complexName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfcomplexName(final Object[] parameters) {
- return rawStreamAllValues(POSITION_COMPLEXNAME, parameters).map(String.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for complexName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfcomplexName() {
- return rawStreamAllValuesOfcomplexName(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for complexName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfcomplexName() {
- return rawStreamAllValuesOfcomplexName(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for complexName.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfcomplexName(final ComplexNameOfElements.Match partialMatch) {
- return rawStreamAllValuesOfcomplexName(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for complexName.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfcomplexName(final NamedElement pElement) {
- return rawStreamAllValuesOfcomplexName(new Object[]{pElement, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for complexName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfcomplexName(final ComplexNameOfElements.Match partialMatch) {
- return rawStreamAllValuesOfcomplexName(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for complexName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfcomplexName(final NamedElement pElement) {
- return rawStreamAllValuesOfcomplexName(new Object[]{pElement, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected ComplexNameOfElements.Match tupleToMatch(final Tuple t) {
- try {
- return ComplexNameOfElements.Match.newMatch((NamedElement) t.get(POSITION_ELEMENT), (String) t.get(POSITION_COMPLEXNAME));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ComplexNameOfElements.Match arrayToMatch(final Object[] match) {
- try {
- return ComplexNameOfElements.Match.newMatch((NamedElement) match[POSITION_ELEMENT], (String) match[POSITION_COMPLEXNAME]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ComplexNameOfElements.Match arrayToMatchMutable(final Object[] match) {
- try {
- return ComplexNameOfElements.Match.newMutableMatch((NamedElement) match[POSITION_ELEMENT], (String) match[POSITION_COMPLEXNAME]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return ComplexNameOfElements.instance();
- }
- }
-
- private ComplexNameOfElements() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ComplexNameOfElements instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected ComplexNameOfElements.Matcher instantiate(final ViatraQueryEngine engine) {
- return ComplexNameOfElements.Matcher.on(engine);
- }
-
- @Override
- public ComplexNameOfElements.Matcher instantiate() {
- return ComplexNameOfElements.Matcher.create();
- }
-
- @Override
- public ComplexNameOfElements.Match newEmptyMatch() {
- return ComplexNameOfElements.Match.newEmptyMatch();
- }
-
- @Override
- public ComplexNameOfElements.Match newMatch(final Object... parameters) {
- return ComplexNameOfElements.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[0], (java.lang.String) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link ComplexNameOfElements} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link ComplexNameOfElements#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final ComplexNameOfElements INSTANCE = new ComplexNameOfElements();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final ComplexNameOfElements.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_element = new PParameter("element", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")), PParameterDirection.INOUT);
-
- private final PParameter parameter_complexName = new PParameter("complexName", "java.lang.String", new JavaTransitiveInstancesKey(java.lang.String.class), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_element, parameter_complexName);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.complexNameOfElements";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("element","complexName");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_element = body.getOrCreateVariableByName("element");
- PVariable var_complexName = body.getOrCreateVariableByName("complexName");
- PVariable var_name = body.getOrCreateVariableByName("name");
- new TypeConstraint(body, Tuples.flatTupleOf(var_element), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_complexName), new JavaTransitiveInstancesKey(java.lang.String.class));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_element, parameter_element),
- new ExportedParameter(body, var_complexName, parameter_complexName)
- ));
- // find namedElement(element, name)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_element, var_name), com.incquerylabs.magicdraw.benchmark.queries.NamedElement.instance().getInternalQueryRepresentation());
- // complexName == eval(name.toFirstUpper + ". "+ name.toFirstLower + "." + name.toUpperCase + "." + name.toLowerCase + "." + name.length)
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new ExpressionEvaluation(body, new IExpressionEvaluator() {
-
- @Override
- public String getShortDescription() {
- return "Expression evaluation from pattern complexNameOfElements";
- }
-
- @Override
- public Iterable getInputParameterNames() {
- return Arrays.asList("name");}
-
- @Override
- public Object evaluateExpression(IValueProvider provider) throws Exception {
- String name = (String) provider.getValue("name");
- return evaluateExpression_1_1(name);
- }
- }, var__virtual_0_ );
- new Equality(body, var_complexName, var__virtual_0_);
- bodies.add(body);
- }
- return bodies;
- }
- }
-
- private static String evaluateExpression_1_1(final String name) {
- String _firstUpper = StringExtensions.toFirstUpper(name);
- String _plus = (_firstUpper + ". ");
- String _firstLower = StringExtensions.toFirstLower(name);
- String _plus_1 = (_plus + _firstLower);
- String _plus_2 = (_plus_1 + ".");
- String _upperCase = name.toUpperCase();
- String _plus_3 = (_plus_2 + _upperCase);
- String _plus_4 = (_plus_3 + ".");
- String _lowerCase = name.toLowerCase();
- String _plus_5 = (_plus_4 + _lowerCase);
- String _plus_6 = (_plus_5 + ".");
- int _length = name.length();
- String _plus_7 = (_plus_6 + Integer.valueOf(_length));
- return _plus_7;
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Dependencies.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Dependencies.java
deleted file mode 100644
index af317c4..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Dependencies.java
+++ /dev/null
@@ -1,717 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Source and target of a dependency element.
- *
- * pattern dependencies(source : NamedElement, target : NamedElement) {
- * Dependency.supplier(dependency, target);
- * Dependency.client(dependency, source);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class Dependencies extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.dependencies pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private NamedElement fSource;
-
- private NamedElement fTarget;
-
- private static List parameterNames = makeImmutableList("source", "target");
-
- private Match(final NamedElement pSource, final NamedElement pTarget) {
- this.fSource = pSource;
- this.fTarget = pTarget;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "source": return this.fSource;
- case "target": return this.fTarget;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fSource;
- case 1: return this.fTarget;
- default: return null;
- }
- }
-
- public NamedElement getSource() {
- return this.fSource;
- }
-
- public NamedElement getTarget() {
- return this.fTarget;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("source".equals(parameterName) ) {
- this.fSource = (NamedElement) newValue;
- return true;
- }
- if ("target".equals(parameterName) ) {
- this.fTarget = (NamedElement) newValue;
- return true;
- }
- return false;
- }
-
- public void setSource(final NamedElement pSource) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fSource = pSource;
- }
-
- public void setTarget(final NamedElement pTarget) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fTarget = pTarget;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.dependencies";
- }
-
- @Override
- public List parameterNames() {
- return Dependencies.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fSource, fTarget};
- }
-
- @Override
- public Dependencies.Match toImmutable() {
- return isMutable() ? newMatch(fSource, fTarget) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"source\"=" + prettyPrintValue(fSource) + ", ");
- result.append("\"target\"=" + prettyPrintValue(fTarget));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fSource, fTarget);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof Dependencies.Match)) {
- Dependencies.Match other = (Dependencies.Match) obj;
- return Objects.equals(fSource, other.fSource) && Objects.equals(fTarget, other.fTarget);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public Dependencies specification() {
- return Dependencies.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static Dependencies.Match newEmptyMatch() {
- return new Mutable(null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static Dependencies.Match newMutableMatch(final NamedElement pSource, final NamedElement pTarget) {
- return new Mutable(pSource, pTarget);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static Dependencies.Match newMatch(final NamedElement pSource, final NamedElement pTarget) {
- return new Immutable(pSource, pTarget);
- }
-
- private static final class Mutable extends Dependencies.Match {
- Mutable(final NamedElement pSource, final NamedElement pTarget) {
- super(pSource, pTarget);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends Dependencies.Match {
- Immutable(final NamedElement pSource, final NamedElement pTarget) {
- super(pSource, pTarget);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.dependencies pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Source and target of a dependency element.
- *
- * pattern dependencies(source : NamedElement, target : NamedElement) {
- * Dependency.supplier(dependency, target);
- * Dependency.client(dependency, source);
- * }
- *
- *
- * @see Match
- * @see Dependencies
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static Dependencies.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static Dependencies.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_SOURCE = 0;
-
- private static final int POSITION_TARGET = 1;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Dependencies.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final NamedElement pSource, final NamedElement pTarget) {
- return rawStreamAllMatches(new Object[]{pSource, pTarget}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final NamedElement pSource, final NamedElement pTarget) {
- return rawStreamAllMatches(new Object[]{pSource, pTarget});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final NamedElement pSource, final NamedElement pTarget) {
- return rawGetOneArbitraryMatch(new Object[]{pSource, pTarget});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final NamedElement pSource, final NamedElement pTarget) {
- return rawHasMatch(new Object[]{pSource, pTarget});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final NamedElement pSource, final NamedElement pTarget) {
- return rawCountMatches(new Object[]{pSource, pTarget});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final NamedElement pSource, final NamedElement pTarget, final Consumer super Dependencies.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pSource, pTarget}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public Dependencies.Match newMatch(final NamedElement pSource, final NamedElement pTarget) {
- return Dependencies.Match.newMatch(pSource, pTarget);
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfsource(final Object[] parameters) {
- return rawStreamAllValues(POSITION_SOURCE, parameters).map(NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource() {
- return rawStreamAllValuesOfsource(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource() {
- return rawStreamAllValuesOfsource(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource(final Dependencies.Match partialMatch) {
- return rawStreamAllValuesOfsource(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource(final NamedElement pTarget) {
- return rawStreamAllValuesOfsource(new Object[]{null, pTarget});
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource(final Dependencies.Match partialMatch) {
- return rawStreamAllValuesOfsource(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource(final NamedElement pTarget) {
- return rawStreamAllValuesOfsource(new Object[]{null, pTarget}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOftarget(final Object[] parameters) {
- return rawStreamAllValues(POSITION_TARGET, parameters).map(NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget() {
- return rawStreamAllValuesOftarget(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget() {
- return rawStreamAllValuesOftarget(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget(final Dependencies.Match partialMatch) {
- return rawStreamAllValuesOftarget(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget(final NamedElement pSource) {
- return rawStreamAllValuesOftarget(new Object[]{pSource, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget(final Dependencies.Match partialMatch) {
- return rawStreamAllValuesOftarget(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget(final NamedElement pSource) {
- return rawStreamAllValuesOftarget(new Object[]{pSource, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected Dependencies.Match tupleToMatch(final Tuple t) {
- try {
- return Dependencies.Match.newMatch((NamedElement) t.get(POSITION_SOURCE), (NamedElement) t.get(POSITION_TARGET));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected Dependencies.Match arrayToMatch(final Object[] match) {
- try {
- return Dependencies.Match.newMatch((NamedElement) match[POSITION_SOURCE], (NamedElement) match[POSITION_TARGET]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected Dependencies.Match arrayToMatchMutable(final Object[] match) {
- try {
- return Dependencies.Match.newMutableMatch((NamedElement) match[POSITION_SOURCE], (NamedElement) match[POSITION_TARGET]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return Dependencies.instance();
- }
- }
-
- private Dependencies() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static Dependencies instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected Dependencies.Matcher instantiate(final ViatraQueryEngine engine) {
- return Dependencies.Matcher.on(engine);
- }
-
- @Override
- public Dependencies.Matcher instantiate() {
- return Dependencies.Matcher.create();
- }
-
- @Override
- public Dependencies.Match newEmptyMatch() {
- return Dependencies.Match.newEmptyMatch();
- }
-
- @Override
- public Dependencies.Match newMatch(final Object... parameters) {
- return Dependencies.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link Dependencies} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link Dependencies#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final Dependencies INSTANCE = new Dependencies();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final Dependencies.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_source = new PParameter("source", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")), PParameterDirection.INOUT);
-
- private final PParameter parameter_target = new PParameter("target", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_source, parameter_target);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.dependencies";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("source","target");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_source = body.getOrCreateVariableByName("source");
- PVariable var_target = body.getOrCreateVariableByName("target");
- PVariable var_dependency = body.getOrCreateVariableByName("dependency");
- new TypeConstraint(body, Tuples.flatTupleOf(var_source), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_source, parameter_source),
- new ExportedParameter(body, var_target, parameter_target)
- ));
- // Dependency.supplier(dependency, target)
- new TypeConstraint(body, Tuples.flatTupleOf(var_dependency), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_dependency, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency", "supplier")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new Equality(body, var__virtual_0_, var_target);
- // Dependency.client(dependency, source)
- new TypeConstraint(body, Tuples.flatTupleOf(var_dependency), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_dependency, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency", "client")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new Equality(body, var__virtual_1_, var_source);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/DependencyChains.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/DependencyChains.java
deleted file mode 100644
index 6cb8dae..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/DependencyChains.java
+++ /dev/null
@@ -1,717 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Pattern describing succession relation between two dependencies.
- *
- * pattern dependencyChains(source : Dependency, target : Dependency) {
- * Dependency.supplier(source, elem);
- * Dependency.client(target, elem);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class DependencyChains extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.dependencyChains pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private Dependency fSource;
-
- private Dependency fTarget;
-
- private static List parameterNames = makeImmutableList("source", "target");
-
- private Match(final Dependency pSource, final Dependency pTarget) {
- this.fSource = pSource;
- this.fTarget = pTarget;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "source": return this.fSource;
- case "target": return this.fTarget;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fSource;
- case 1: return this.fTarget;
- default: return null;
- }
- }
-
- public Dependency getSource() {
- return this.fSource;
- }
-
- public Dependency getTarget() {
- return this.fTarget;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("source".equals(parameterName) ) {
- this.fSource = (Dependency) newValue;
- return true;
- }
- if ("target".equals(parameterName) ) {
- this.fTarget = (Dependency) newValue;
- return true;
- }
- return false;
- }
-
- public void setSource(final Dependency pSource) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fSource = pSource;
- }
-
- public void setTarget(final Dependency pTarget) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fTarget = pTarget;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.dependencyChains";
- }
-
- @Override
- public List parameterNames() {
- return DependencyChains.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fSource, fTarget};
- }
-
- @Override
- public DependencyChains.Match toImmutable() {
- return isMutable() ? newMatch(fSource, fTarget) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"source\"=" + prettyPrintValue(fSource) + ", ");
- result.append("\"target\"=" + prettyPrintValue(fTarget));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fSource, fTarget);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof DependencyChains.Match)) {
- DependencyChains.Match other = (DependencyChains.Match) obj;
- return Objects.equals(fSource, other.fSource) && Objects.equals(fTarget, other.fTarget);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public DependencyChains specification() {
- return DependencyChains.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static DependencyChains.Match newEmptyMatch() {
- return new Mutable(null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static DependencyChains.Match newMutableMatch(final Dependency pSource, final Dependency pTarget) {
- return new Mutable(pSource, pTarget);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static DependencyChains.Match newMatch(final Dependency pSource, final Dependency pTarget) {
- return new Immutable(pSource, pTarget);
- }
-
- private static final class Mutable extends DependencyChains.Match {
- Mutable(final Dependency pSource, final Dependency pTarget) {
- super(pSource, pTarget);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends DependencyChains.Match {
- Immutable(final Dependency pSource, final Dependency pTarget) {
- super(pSource, pTarget);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.dependencyChains pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Pattern describing succession relation between two dependencies.
- *
- * pattern dependencyChains(source : Dependency, target : Dependency) {
- * Dependency.supplier(source, elem);
- * Dependency.client(target, elem);
- * }
- *
- *
- * @see Match
- * @see DependencyChains
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static DependencyChains.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static DependencyChains.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_SOURCE = 0;
-
- private static final int POSITION_TARGET = 1;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(DependencyChains.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final Dependency pSource, final Dependency pTarget) {
- return rawStreamAllMatches(new Object[]{pSource, pTarget}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final Dependency pSource, final Dependency pTarget) {
- return rawStreamAllMatches(new Object[]{pSource, pTarget});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final Dependency pSource, final Dependency pTarget) {
- return rawGetOneArbitraryMatch(new Object[]{pSource, pTarget});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final Dependency pSource, final Dependency pTarget) {
- return rawHasMatch(new Object[]{pSource, pTarget});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final Dependency pSource, final Dependency pTarget) {
- return rawCountMatches(new Object[]{pSource, pTarget});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final Dependency pSource, final Dependency pTarget, final Consumer super DependencyChains.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pSource, pTarget}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public DependencyChains.Match newMatch(final Dependency pSource, final Dependency pTarget) {
- return DependencyChains.Match.newMatch(pSource, pTarget);
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfsource(final Object[] parameters) {
- return rawStreamAllValues(POSITION_SOURCE, parameters).map(Dependency.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource() {
- return rawStreamAllValuesOfsource(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource() {
- return rawStreamAllValuesOfsource(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource(final DependencyChains.Match partialMatch) {
- return rawStreamAllValuesOfsource(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource(final Dependency pTarget) {
- return rawStreamAllValuesOfsource(new Object[]{null, pTarget});
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource(final DependencyChains.Match partialMatch) {
- return rawStreamAllValuesOfsource(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource(final Dependency pTarget) {
- return rawStreamAllValuesOfsource(new Object[]{null, pTarget}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOftarget(final Object[] parameters) {
- return rawStreamAllValues(POSITION_TARGET, parameters).map(Dependency.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget() {
- return rawStreamAllValuesOftarget(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget() {
- return rawStreamAllValuesOftarget(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget(final DependencyChains.Match partialMatch) {
- return rawStreamAllValuesOftarget(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget(final Dependency pSource) {
- return rawStreamAllValuesOftarget(new Object[]{pSource, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget(final DependencyChains.Match partialMatch) {
- return rawStreamAllValuesOftarget(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget(final Dependency pSource) {
- return rawStreamAllValuesOftarget(new Object[]{pSource, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected DependencyChains.Match tupleToMatch(final Tuple t) {
- try {
- return DependencyChains.Match.newMatch((Dependency) t.get(POSITION_SOURCE), (Dependency) t.get(POSITION_TARGET));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected DependencyChains.Match arrayToMatch(final Object[] match) {
- try {
- return DependencyChains.Match.newMatch((Dependency) match[POSITION_SOURCE], (Dependency) match[POSITION_TARGET]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected DependencyChains.Match arrayToMatchMutable(final Object[] match) {
- try {
- return DependencyChains.Match.newMutableMatch((Dependency) match[POSITION_SOURCE], (Dependency) match[POSITION_TARGET]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return DependencyChains.instance();
- }
- }
-
- private DependencyChains() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static DependencyChains instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected DependencyChains.Matcher instantiate(final ViatraQueryEngine engine) {
- return DependencyChains.Matcher.on(engine);
- }
-
- @Override
- public DependencyChains.Matcher instantiate() {
- return DependencyChains.Matcher.create();
- }
-
- @Override
- public DependencyChains.Match newEmptyMatch() {
- return DependencyChains.Match.newEmptyMatch();
- }
-
- @Override
- public DependencyChains.Match newMatch(final Object... parameters) {
- return DependencyChains.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link DependencyChains} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link DependencyChains#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final DependencyChains INSTANCE = new DependencyChains();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final DependencyChains.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_source = new PParameter("source", "com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency")), PParameterDirection.INOUT);
-
- private final PParameter parameter_target = new PParameter("target", "com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_source, parameter_target);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.dependencyChains";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("source","target");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_source = body.getOrCreateVariableByName("source");
- PVariable var_target = body.getOrCreateVariableByName("target");
- PVariable var_elem = body.getOrCreateVariableByName("elem");
- new TypeConstraint(body, Tuples.flatTupleOf(var_source), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_source, parameter_source),
- new ExportedParameter(body, var_target, parameter_target)
- ));
- // Dependency.supplier(source, elem)
- new TypeConstraint(body, Tuples.flatTupleOf(var_source), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_source, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency", "supplier")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new Equality(body, var__virtual_0_, var_elem);
- // Dependency.client(target, elem)
- new TypeConstraint(body, Tuples.flatTupleOf(var_target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_target, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency", "client")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new Equality(body, var__virtual_1_, var_elem);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/ElementsWithShortNames.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/ElementsWithShortNames.java
deleted file mode 100644
index ecc83c7..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/ElementsWithShortNames.java
+++ /dev/null
@@ -1,586 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
-import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Simple filtering with a check on all instances of an EClass.
- *
- * pattern elementsWithShortNames(class : NamedElement) {
- * NamedElement.name(class, name);
- * check (name.length {@literal <} 10);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class ElementsWithShortNames extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.elementsWithShortNames pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private NamedElement fClass;
-
- private static List parameterNames = makeImmutableList("class");
-
- private Match(final NamedElement pClass) {
- this.fClass = pClass;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "class": return this.fClass;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fClass;
- default: return null;
- }
- }
-
- public NamedElement getValueOfClass() {
- return this.fClass;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("class".equals(parameterName) ) {
- this.fClass = (NamedElement) newValue;
- return true;
- }
- return false;
- }
-
- public void setClass(final NamedElement pClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass = pClass;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.elementsWithShortNames";
- }
-
- @Override
- public List parameterNames() {
- return ElementsWithShortNames.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass};
- }
-
- @Override
- public ElementsWithShortNames.Match toImmutable() {
- return isMutable() ? newMatch(fClass) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof ElementsWithShortNames.Match)) {
- ElementsWithShortNames.Match other = (ElementsWithShortNames.Match) obj;
- return Objects.equals(fClass, other.fClass);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public ElementsWithShortNames specification() {
- return ElementsWithShortNames.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static ElementsWithShortNames.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static ElementsWithShortNames.Match newMutableMatch(final NamedElement pClass) {
- return new Mutable(pClass);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static ElementsWithShortNames.Match newMatch(final NamedElement pClass) {
- return new Immutable(pClass);
- }
-
- private static final class Mutable extends ElementsWithShortNames.Match {
- Mutable(final NamedElement pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends ElementsWithShortNames.Match {
- Immutable(final NamedElement pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.elementsWithShortNames pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Simple filtering with a check on all instances of an EClass.
- *
- * pattern elementsWithShortNames(class : NamedElement) {
- * NamedElement.name(class, name);
- * check (name.length {@literal <} 10);
- * }
- *
- *
- * @see Match
- * @see ElementsWithShortNames
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static ElementsWithShortNames.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static ElementsWithShortNames.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_CLASS = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ElementsWithShortNames.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final NamedElement pClass) {
- return rawStreamAllMatches(new Object[]{pClass}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final NamedElement pClass) {
- return rawStreamAllMatches(new Object[]{pClass});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final NamedElement pClass) {
- return rawGetOneArbitraryMatch(new Object[]{pClass});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final NamedElement pClass) {
- return rawHasMatch(new Object[]{pClass});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final NamedElement pClass) {
- return rawCountMatches(new Object[]{pClass});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final NamedElement pClass, final Consumer super ElementsWithShortNames.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public ElementsWithShortNames.Match newMatch(final NamedElement pClass) {
- return ElementsWithShortNames.Match.newMatch(pClass);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfclass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_CLASS, parameters).map(NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray());
- }
-
- @Override
- protected ElementsWithShortNames.Match tupleToMatch(final Tuple t) {
- try {
- return ElementsWithShortNames.Match.newMatch((NamedElement) t.get(POSITION_CLASS));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ElementsWithShortNames.Match arrayToMatch(final Object[] match) {
- try {
- return ElementsWithShortNames.Match.newMatch((NamedElement) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ElementsWithShortNames.Match arrayToMatchMutable(final Object[] match) {
- try {
- return ElementsWithShortNames.Match.newMutableMatch((NamedElement) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return ElementsWithShortNames.instance();
- }
- }
-
- private ElementsWithShortNames() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ElementsWithShortNames instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected ElementsWithShortNames.Matcher instantiate(final ViatraQueryEngine engine) {
- return ElementsWithShortNames.Matcher.on(engine);
- }
-
- @Override
- public ElementsWithShortNames.Matcher instantiate() {
- return ElementsWithShortNames.Matcher.create();
- }
-
- @Override
- public ElementsWithShortNames.Match newEmptyMatch() {
- return ElementsWithShortNames.Match.newEmptyMatch();
- }
-
- @Override
- public ElementsWithShortNames.Match newMatch(final Object... parameters) {
- return ElementsWithShortNames.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link ElementsWithShortNames} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link ElementsWithShortNames#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final ElementsWithShortNames INSTANCE = new ElementsWithShortNames();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final ElementsWithShortNames.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_class = new PParameter("class", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.elementsWithShortNames";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_class = body.getOrCreateVariableByName("class");
- PVariable var_name = body.getOrCreateVariableByName("name");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class)
- ));
- // NamedElement.name(class, name)
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement", "name")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "String")));
- new Equality(body, var__virtual_0_, var_name);
- // check (name.length < 10)
- new ExpressionEvaluation(body, new IExpressionEvaluator() {
-
- @Override
- public String getShortDescription() {
- return "Expression evaluation from pattern elementsWithShortNames";
- }
-
- @Override
- public Iterable getInputParameterNames() {
- return Arrays.asList("name");}
-
- @Override
- public Object evaluateExpression(IValueProvider provider) throws Exception {
- String name = (String) provider.getValue("name");
- return evaluateExpression_1_1(name);
- }
- }, null);
- bodies.add(body);
- }
- return bodies;
- }
- }
-
- private static boolean evaluateExpression_1_1(final String name) {
- int _length = name.length();
- boolean _lessThan = (_length < 10);
- return _lessThan;
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/IncomingTransitions.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/IncomingTransitions.java
deleted file mode 100644
index 1475654..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/IncomingTransitions.java
+++ /dev/null
@@ -1,709 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State;
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.Transition;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Returns transitions with their targets. Made for reuse.
- *
- * pattern incomingTransitions(transition : Transition, targetState : State) {
- * Transition.target(transition, targetState);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class IncomingTransitions extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.incomingTransitions pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private Transition fTransition;
-
- private State fTargetState;
-
- private static List parameterNames = makeImmutableList("transition", "targetState");
-
- private Match(final Transition pTransition, final State pTargetState) {
- this.fTransition = pTransition;
- this.fTargetState = pTargetState;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "transition": return this.fTransition;
- case "targetState": return this.fTargetState;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fTransition;
- case 1: return this.fTargetState;
- default: return null;
- }
- }
-
- public Transition getTransition() {
- return this.fTransition;
- }
-
- public State getTargetState() {
- return this.fTargetState;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("transition".equals(parameterName) ) {
- this.fTransition = (Transition) newValue;
- return true;
- }
- if ("targetState".equals(parameterName) ) {
- this.fTargetState = (State) newValue;
- return true;
- }
- return false;
- }
-
- public void setTransition(final Transition pTransition) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fTransition = pTransition;
- }
-
- public void setTargetState(final State pTargetState) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fTargetState = pTargetState;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.incomingTransitions";
- }
-
- @Override
- public List parameterNames() {
- return IncomingTransitions.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fTransition, fTargetState};
- }
-
- @Override
- public IncomingTransitions.Match toImmutable() {
- return isMutable() ? newMatch(fTransition, fTargetState) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"transition\"=" + prettyPrintValue(fTransition) + ", ");
- result.append("\"targetState\"=" + prettyPrintValue(fTargetState));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fTransition, fTargetState);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof IncomingTransitions.Match)) {
- IncomingTransitions.Match other = (IncomingTransitions.Match) obj;
- return Objects.equals(fTransition, other.fTransition) && Objects.equals(fTargetState, other.fTargetState);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public IncomingTransitions specification() {
- return IncomingTransitions.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static IncomingTransitions.Match newEmptyMatch() {
- return new Mutable(null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTargetState the fixed value of pattern parameter targetState, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static IncomingTransitions.Match newMutableMatch(final Transition pTransition, final State pTargetState) {
- return new Mutable(pTransition, pTargetState);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTargetState the fixed value of pattern parameter targetState, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static IncomingTransitions.Match newMatch(final Transition pTransition, final State pTargetState) {
- return new Immutable(pTransition, pTargetState);
- }
-
- private static final class Mutable extends IncomingTransitions.Match {
- Mutable(final Transition pTransition, final State pTargetState) {
- super(pTransition, pTargetState);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends IncomingTransitions.Match {
- Immutable(final Transition pTransition, final State pTargetState) {
- super(pTransition, pTargetState);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.incomingTransitions pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Returns transitions with their targets. Made for reuse.
- *
- * pattern incomingTransitions(transition : Transition, targetState : State) {
- * Transition.target(transition, targetState);
- * }
- *
- *
- * @see Match
- * @see IncomingTransitions
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static IncomingTransitions.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static IncomingTransitions.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_TRANSITION = 0;
-
- private static final int POSITION_TARGETSTATE = 1;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(IncomingTransitions.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTargetState the fixed value of pattern parameter targetState, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final Transition pTransition, final State pTargetState) {
- return rawStreamAllMatches(new Object[]{pTransition, pTargetState}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTargetState the fixed value of pattern parameter targetState, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final Transition pTransition, final State pTargetState) {
- return rawStreamAllMatches(new Object[]{pTransition, pTargetState});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTargetState the fixed value of pattern parameter targetState, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final Transition pTransition, final State pTargetState) {
- return rawGetOneArbitraryMatch(new Object[]{pTransition, pTargetState});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTargetState the fixed value of pattern parameter targetState, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final Transition pTransition, final State pTargetState) {
- return rawHasMatch(new Object[]{pTransition, pTargetState});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTargetState the fixed value of pattern parameter targetState, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final Transition pTransition, final State pTargetState) {
- return rawCountMatches(new Object[]{pTransition, pTargetState});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTargetState the fixed value of pattern parameter targetState, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final Transition pTransition, final State pTargetState, final Consumer super IncomingTransitions.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pTransition, pTargetState}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTargetState the fixed value of pattern parameter targetState, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public IncomingTransitions.Match newMatch(final Transition pTransition, final State pTargetState) {
- return IncomingTransitions.Match.newMatch(pTransition, pTargetState);
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOftransition(final Object[] parameters) {
- return rawStreamAllValues(POSITION_TRANSITION, parameters).map(Transition.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftransition() {
- return rawStreamAllValuesOftransition(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftransition() {
- return rawStreamAllValuesOftransition(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftransition(final IncomingTransitions.Match partialMatch) {
- return rawStreamAllValuesOftransition(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftransition(final State pTargetState) {
- return rawStreamAllValuesOftransition(new Object[]{null, pTargetState});
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftransition(final IncomingTransitions.Match partialMatch) {
- return rawStreamAllValuesOftransition(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftransition(final State pTargetState) {
- return rawStreamAllValuesOftransition(new Object[]{null, pTargetState}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOftargetState(final Object[] parameters) {
- return rawStreamAllValues(POSITION_TARGETSTATE, parameters).map(State.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftargetState() {
- return rawStreamAllValuesOftargetState(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftargetState() {
- return rawStreamAllValuesOftargetState(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetState.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftargetState(final IncomingTransitions.Match partialMatch) {
- return rawStreamAllValuesOftargetState(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetState.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftargetState(final Transition pTransition) {
- return rawStreamAllValuesOftargetState(new Object[]{pTransition, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftargetState(final IncomingTransitions.Match partialMatch) {
- return rawStreamAllValuesOftargetState(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftargetState(final Transition pTransition) {
- return rawStreamAllValuesOftargetState(new Object[]{pTransition, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected IncomingTransitions.Match tupleToMatch(final Tuple t) {
- try {
- return IncomingTransitions.Match.newMatch((Transition) t.get(POSITION_TRANSITION), (State) t.get(POSITION_TARGETSTATE));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected IncomingTransitions.Match arrayToMatch(final Object[] match) {
- try {
- return IncomingTransitions.Match.newMatch((Transition) match[POSITION_TRANSITION], (State) match[POSITION_TARGETSTATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected IncomingTransitions.Match arrayToMatchMutable(final Object[] match) {
- try {
- return IncomingTransitions.Match.newMutableMatch((Transition) match[POSITION_TRANSITION], (State) match[POSITION_TARGETSTATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return IncomingTransitions.instance();
- }
- }
-
- private IncomingTransitions() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IncomingTransitions instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected IncomingTransitions.Matcher instantiate(final ViatraQueryEngine engine) {
- return IncomingTransitions.Matcher.on(engine);
- }
-
- @Override
- public IncomingTransitions.Matcher instantiate() {
- return IncomingTransitions.Matcher.create();
- }
-
- @Override
- public IncomingTransitions.Match newEmptyMatch() {
- return IncomingTransitions.Match.newEmptyMatch();
- }
-
- @Override
- public IncomingTransitions.Match newMatch(final Object... parameters) {
- return IncomingTransitions.Match.newMatch((com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.Transition) parameters[0], (com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link IncomingTransitions} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link IncomingTransitions#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final IncomingTransitions INSTANCE = new IncomingTransitions();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final IncomingTransitions.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_transition = new PParameter("transition", "com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.Transition", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition")), PParameterDirection.INOUT);
-
- private final PParameter parameter_targetState = new PParameter("targetState", "com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_transition, parameter_targetState);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.incomingTransitions";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("transition","targetState");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_transition = body.getOrCreateVariableByName("transition");
- PVariable var_targetState = body.getOrCreateVariableByName("targetState");
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_targetState), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_transition, parameter_transition),
- new ExportedParameter(body, var_targetState, parameter_targetState)
- ));
- // Transition.target(transition, targetState)
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition", "target")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Vertex")));
- new Equality(body, var__virtual_0_, var_targetState);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/LoopTransitionWithTriggerEffectEventNoGuard.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/LoopTransitionWithTriggerEffectEventNoGuard.java
deleted file mode 100644
index 3111071..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/LoopTransitionWithTriggerEffectEventNoGuard.java
+++ /dev/null
@@ -1,1098 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.internal.TransitionWithGuard;
-import com.nomagic.uml2.ext.magicdraw.activities.mdfundamentalactivities.Activity;
-import com.nomagic.uml2.ext.magicdraw.commonbehaviors.mdcommunications.Event;
-import com.nomagic.uml2.ext.magicdraw.commonbehaviors.mdcommunications.Trigger;
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State;
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.Transition;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * A loop transition that
- * - Has a trigger
- * - Has some effect that is an activity
- * - Has no guard
- * - defines an event
- *
- *
- * pattern loopTransitionWithTriggerEffectEventNoGuard(state : State, transition : Transition, trigger : Trigger, event : Event, effect : Activity) {
- * Transition.source(transition, state);
- * Transition.target(transition, state);
- * Transition.kind(transition, ::external);
- * Transition.trigger(transition, trigger);
- * Transition.effect(transition, effect);
- * neg find transitionWithGuard(transition, _);
- * Trigger.event(trigger, event);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class LoopTransitionWithTriggerEffectEventNoGuard extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.loopTransitionWithTriggerEffectEventNoGuard pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private State fState;
-
- private Transition fTransition;
-
- private Trigger fTrigger;
-
- private Event fEvent;
-
- private Activity fEffect;
-
- private static List parameterNames = makeImmutableList("state", "transition", "trigger", "event", "effect");
-
- private Match(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- this.fState = pState;
- this.fTransition = pTransition;
- this.fTrigger = pTrigger;
- this.fEvent = pEvent;
- this.fEffect = pEffect;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "state": return this.fState;
- case "transition": return this.fTransition;
- case "trigger": return this.fTrigger;
- case "event": return this.fEvent;
- case "effect": return this.fEffect;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fState;
- case 1: return this.fTransition;
- case 2: return this.fTrigger;
- case 3: return this.fEvent;
- case 4: return this.fEffect;
- default: return null;
- }
- }
-
- public State getState() {
- return this.fState;
- }
-
- public Transition getTransition() {
- return this.fTransition;
- }
-
- public Trigger getTrigger() {
- return this.fTrigger;
- }
-
- public Event getEvent() {
- return this.fEvent;
- }
-
- public Activity getEffect() {
- return this.fEffect;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("state".equals(parameterName) ) {
- this.fState = (State) newValue;
- return true;
- }
- if ("transition".equals(parameterName) ) {
- this.fTransition = (Transition) newValue;
- return true;
- }
- if ("trigger".equals(parameterName) ) {
- this.fTrigger = (Trigger) newValue;
- return true;
- }
- if ("event".equals(parameterName) ) {
- this.fEvent = (Event) newValue;
- return true;
- }
- if ("effect".equals(parameterName) ) {
- this.fEffect = (Activity) newValue;
- return true;
- }
- return false;
- }
-
- public void setState(final State pState) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fState = pState;
- }
-
- public void setTransition(final Transition pTransition) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fTransition = pTransition;
- }
-
- public void setTrigger(final Trigger pTrigger) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fTrigger = pTrigger;
- }
-
- public void setEvent(final Event pEvent) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fEvent = pEvent;
- }
-
- public void setEffect(final Activity pEffect) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fEffect = pEffect;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.loopTransitionWithTriggerEffectEventNoGuard";
- }
-
- @Override
- public List parameterNames() {
- return LoopTransitionWithTriggerEffectEventNoGuard.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fState, fTransition, fTrigger, fEvent, fEffect};
- }
-
- @Override
- public LoopTransitionWithTriggerEffectEventNoGuard.Match toImmutable() {
- return isMutable() ? newMatch(fState, fTransition, fTrigger, fEvent, fEffect) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"state\"=" + prettyPrintValue(fState) + ", ");
- result.append("\"transition\"=" + prettyPrintValue(fTransition) + ", ");
- result.append("\"trigger\"=" + prettyPrintValue(fTrigger) + ", ");
- result.append("\"event\"=" + prettyPrintValue(fEvent) + ", ");
- result.append("\"effect\"=" + prettyPrintValue(fEffect));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fState, fTransition, fTrigger, fEvent, fEffect);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof LoopTransitionWithTriggerEffectEventNoGuard.Match)) {
- LoopTransitionWithTriggerEffectEventNoGuard.Match other = (LoopTransitionWithTriggerEffectEventNoGuard.Match) obj;
- return Objects.equals(fState, other.fState) && Objects.equals(fTransition, other.fTransition) && Objects.equals(fTrigger, other.fTrigger) && Objects.equals(fEvent, other.fEvent) && Objects.equals(fEffect, other.fEffect);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public LoopTransitionWithTriggerEffectEventNoGuard specification() {
- return LoopTransitionWithTriggerEffectEventNoGuard.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static LoopTransitionWithTriggerEffectEventNoGuard.Match newEmptyMatch() {
- return new Mutable(null, null, null, null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTrigger the fixed value of pattern parameter trigger, or null if not bound.
- * @param pEvent the fixed value of pattern parameter event, or null if not bound.
- * @param pEffect the fixed value of pattern parameter effect, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static LoopTransitionWithTriggerEffectEventNoGuard.Match newMutableMatch(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return new Mutable(pState, pTransition, pTrigger, pEvent, pEffect);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTrigger the fixed value of pattern parameter trigger, or null if not bound.
- * @param pEvent the fixed value of pattern parameter event, or null if not bound.
- * @param pEffect the fixed value of pattern parameter effect, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static LoopTransitionWithTriggerEffectEventNoGuard.Match newMatch(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return new Immutable(pState, pTransition, pTrigger, pEvent, pEffect);
- }
-
- private static final class Mutable extends LoopTransitionWithTriggerEffectEventNoGuard.Match {
- Mutable(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- super(pState, pTransition, pTrigger, pEvent, pEffect);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends LoopTransitionWithTriggerEffectEventNoGuard.Match {
- Immutable(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- super(pState, pTransition, pTrigger, pEvent, pEffect);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.loopTransitionWithTriggerEffectEventNoGuard pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * A loop transition that
- * - Has a trigger
- * - Has some effect that is an activity
- * - Has no guard
- * - defines an event
- *
- *
- * pattern loopTransitionWithTriggerEffectEventNoGuard(state : State, transition : Transition, trigger : Trigger, event : Event, effect : Activity) {
- * Transition.source(transition, state);
- * Transition.target(transition, state);
- * Transition.kind(transition, ::external);
- * Transition.trigger(transition, trigger);
- * Transition.effect(transition, effect);
- * neg find transitionWithGuard(transition, _);
- * Trigger.event(trigger, event);
- * }
- *
- *
- * @see Match
- * @see LoopTransitionWithTriggerEffectEventNoGuard
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static LoopTransitionWithTriggerEffectEventNoGuard.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static LoopTransitionWithTriggerEffectEventNoGuard.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_STATE = 0;
-
- private static final int POSITION_TRANSITION = 1;
-
- private static final int POSITION_TRIGGER = 2;
-
- private static final int POSITION_EVENT = 3;
-
- private static final int POSITION_EFFECT = 4;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(LoopTransitionWithTriggerEffectEventNoGuard.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTrigger the fixed value of pattern parameter trigger, or null if not bound.
- * @param pEvent the fixed value of pattern parameter event, or null if not bound.
- * @param pEffect the fixed value of pattern parameter effect, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return rawStreamAllMatches(new Object[]{pState, pTransition, pTrigger, pEvent, pEffect}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTrigger the fixed value of pattern parameter trigger, or null if not bound.
- * @param pEvent the fixed value of pattern parameter event, or null if not bound.
- * @param pEffect the fixed value of pattern parameter effect, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return rawStreamAllMatches(new Object[]{pState, pTransition, pTrigger, pEvent, pEffect});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTrigger the fixed value of pattern parameter trigger, or null if not bound.
- * @param pEvent the fixed value of pattern parameter event, or null if not bound.
- * @param pEffect the fixed value of pattern parameter effect, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return rawGetOneArbitraryMatch(new Object[]{pState, pTransition, pTrigger, pEvent, pEffect});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTrigger the fixed value of pattern parameter trigger, or null if not bound.
- * @param pEvent the fixed value of pattern parameter event, or null if not bound.
- * @param pEffect the fixed value of pattern parameter effect, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return rawHasMatch(new Object[]{pState, pTransition, pTrigger, pEvent, pEffect});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTrigger the fixed value of pattern parameter trigger, or null if not bound.
- * @param pEvent the fixed value of pattern parameter event, or null if not bound.
- * @param pEffect the fixed value of pattern parameter effect, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return rawCountMatches(new Object[]{pState, pTransition, pTrigger, pEvent, pEffect});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTrigger the fixed value of pattern parameter trigger, or null if not bound.
- * @param pEvent the fixed value of pattern parameter event, or null if not bound.
- * @param pEffect the fixed value of pattern parameter effect, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect, final Consumer super LoopTransitionWithTriggerEffectEventNoGuard.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pState, pTransition, pTrigger, pEvent, pEffect}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransition the fixed value of pattern parameter transition, or null if not bound.
- * @param pTrigger the fixed value of pattern parameter trigger, or null if not bound.
- * @param pEvent the fixed value of pattern parameter event, or null if not bound.
- * @param pEffect the fixed value of pattern parameter effect, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public LoopTransitionWithTriggerEffectEventNoGuard.Match newMatch(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return LoopTransitionWithTriggerEffectEventNoGuard.Match.newMatch(pState, pTransition, pTrigger, pEvent, pEffect);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfstate(final Object[] parameters) {
- return rawStreamAllValues(POSITION_STATE, parameters).map(State.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate(final LoopTransitionWithTriggerEffectEventNoGuard.Match partialMatch) {
- return rawStreamAllValuesOfstate(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate(final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return rawStreamAllValuesOfstate(new Object[]{null, pTransition, pTrigger, pEvent, pEffect});
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate(final LoopTransitionWithTriggerEffectEventNoGuard.Match partialMatch) {
- return rawStreamAllValuesOfstate(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate(final Transition pTransition, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return rawStreamAllValuesOfstate(new Object[]{null, pTransition, pTrigger, pEvent, pEffect}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOftransition(final Object[] parameters) {
- return rawStreamAllValues(POSITION_TRANSITION, parameters).map(Transition.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftransition() {
- return rawStreamAllValuesOftransition(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftransition() {
- return rawStreamAllValuesOftransition(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftransition(final LoopTransitionWithTriggerEffectEventNoGuard.Match partialMatch) {
- return rawStreamAllValuesOftransition(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftransition(final State pState, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return rawStreamAllValuesOftransition(new Object[]{pState, null, pTrigger, pEvent, pEffect});
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftransition(final LoopTransitionWithTriggerEffectEventNoGuard.Match partialMatch) {
- return rawStreamAllValuesOftransition(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transition.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftransition(final State pState, final Trigger pTrigger, final Event pEvent, final Activity pEffect) {
- return rawStreamAllValuesOftransition(new Object[]{pState, null, pTrigger, pEvent, pEffect}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for trigger.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOftrigger(final Object[] parameters) {
- return rawStreamAllValues(POSITION_TRIGGER, parameters).map(Trigger.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for trigger.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftrigger() {
- return rawStreamAllValuesOftrigger(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for trigger.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftrigger() {
- return rawStreamAllValuesOftrigger(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for trigger.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftrigger(final LoopTransitionWithTriggerEffectEventNoGuard.Match partialMatch) {
- return rawStreamAllValuesOftrigger(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for trigger.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftrigger(final State pState, final Transition pTransition, final Event pEvent, final Activity pEffect) {
- return rawStreamAllValuesOftrigger(new Object[]{pState, pTransition, null, pEvent, pEffect});
- }
-
- /**
- * Retrieve the set of values that occur in matches for trigger.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftrigger(final LoopTransitionWithTriggerEffectEventNoGuard.Match partialMatch) {
- return rawStreamAllValuesOftrigger(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for trigger.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftrigger(final State pState, final Transition pTransition, final Event pEvent, final Activity pEffect) {
- return rawStreamAllValuesOftrigger(new Object[]{pState, pTransition, null, pEvent, pEffect}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for event.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfevent(final Object[] parameters) {
- return rawStreamAllValues(POSITION_EVENT, parameters).map(Event.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for event.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfevent() {
- return rawStreamAllValuesOfevent(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for event.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfevent() {
- return rawStreamAllValuesOfevent(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for event.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfevent(final LoopTransitionWithTriggerEffectEventNoGuard.Match partialMatch) {
- return rawStreamAllValuesOfevent(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for event.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfevent(final State pState, final Transition pTransition, final Trigger pTrigger, final Activity pEffect) {
- return rawStreamAllValuesOfevent(new Object[]{pState, pTransition, pTrigger, null, pEffect});
- }
-
- /**
- * Retrieve the set of values that occur in matches for event.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfevent(final LoopTransitionWithTriggerEffectEventNoGuard.Match partialMatch) {
- return rawStreamAllValuesOfevent(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for event.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfevent(final State pState, final Transition pTransition, final Trigger pTrigger, final Activity pEffect) {
- return rawStreamAllValuesOfevent(new Object[]{pState, pTransition, pTrigger, null, pEffect}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for effect.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfeffect(final Object[] parameters) {
- return rawStreamAllValues(POSITION_EFFECT, parameters).map(Activity.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for effect.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfeffect() {
- return rawStreamAllValuesOfeffect(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for effect.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfeffect() {
- return rawStreamAllValuesOfeffect(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for effect.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfeffect(final LoopTransitionWithTriggerEffectEventNoGuard.Match partialMatch) {
- return rawStreamAllValuesOfeffect(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for effect.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfeffect(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent) {
- return rawStreamAllValuesOfeffect(new Object[]{pState, pTransition, pTrigger, pEvent, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for effect.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfeffect(final LoopTransitionWithTriggerEffectEventNoGuard.Match partialMatch) {
- return rawStreamAllValuesOfeffect(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for effect.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfeffect(final State pState, final Transition pTransition, final Trigger pTrigger, final Event pEvent) {
- return rawStreamAllValuesOfeffect(new Object[]{pState, pTransition, pTrigger, pEvent, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected LoopTransitionWithTriggerEffectEventNoGuard.Match tupleToMatch(final Tuple t) {
- try {
- return LoopTransitionWithTriggerEffectEventNoGuard.Match.newMatch((State) t.get(POSITION_STATE), (Transition) t.get(POSITION_TRANSITION), (Trigger) t.get(POSITION_TRIGGER), (Event) t.get(POSITION_EVENT), (Activity) t.get(POSITION_EFFECT));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected LoopTransitionWithTriggerEffectEventNoGuard.Match arrayToMatch(final Object[] match) {
- try {
- return LoopTransitionWithTriggerEffectEventNoGuard.Match.newMatch((State) match[POSITION_STATE], (Transition) match[POSITION_TRANSITION], (Trigger) match[POSITION_TRIGGER], (Event) match[POSITION_EVENT], (Activity) match[POSITION_EFFECT]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected LoopTransitionWithTriggerEffectEventNoGuard.Match arrayToMatchMutable(final Object[] match) {
- try {
- return LoopTransitionWithTriggerEffectEventNoGuard.Match.newMutableMatch((State) match[POSITION_STATE], (Transition) match[POSITION_TRANSITION], (Trigger) match[POSITION_TRIGGER], (Event) match[POSITION_EVENT], (Activity) match[POSITION_EFFECT]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return LoopTransitionWithTriggerEffectEventNoGuard.instance();
- }
- }
-
- private LoopTransitionWithTriggerEffectEventNoGuard() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static LoopTransitionWithTriggerEffectEventNoGuard instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected LoopTransitionWithTriggerEffectEventNoGuard.Matcher instantiate(final ViatraQueryEngine engine) {
- return LoopTransitionWithTriggerEffectEventNoGuard.Matcher.on(engine);
- }
-
- @Override
- public LoopTransitionWithTriggerEffectEventNoGuard.Matcher instantiate() {
- return LoopTransitionWithTriggerEffectEventNoGuard.Matcher.create();
- }
-
- @Override
- public LoopTransitionWithTriggerEffectEventNoGuard.Match newEmptyMatch() {
- return LoopTransitionWithTriggerEffectEventNoGuard.Match.newEmptyMatch();
- }
-
- @Override
- public LoopTransitionWithTriggerEffectEventNoGuard.Match newMatch(final Object... parameters) {
- return LoopTransitionWithTriggerEffectEventNoGuard.Match.newMatch((com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State) parameters[0], (com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.Transition) parameters[1], (com.nomagic.uml2.ext.magicdraw.commonbehaviors.mdcommunications.Trigger) parameters[2], (com.nomagic.uml2.ext.magicdraw.commonbehaviors.mdcommunications.Event) parameters[3], (com.nomagic.uml2.ext.magicdraw.activities.mdfundamentalactivities.Activity) parameters[4]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link LoopTransitionWithTriggerEffectEventNoGuard} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link LoopTransitionWithTriggerEffectEventNoGuard#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final LoopTransitionWithTriggerEffectEventNoGuard INSTANCE = new LoopTransitionWithTriggerEffectEventNoGuard();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final LoopTransitionWithTriggerEffectEventNoGuard.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_state = new PParameter("state", "com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")), PParameterDirection.INOUT);
-
- private final PParameter parameter_transition = new PParameter("transition", "com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.Transition", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition")), PParameterDirection.INOUT);
-
- private final PParameter parameter_trigger = new PParameter("trigger", "com.nomagic.uml2.ext.magicdraw.commonbehaviors.mdcommunications.Trigger", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Trigger")), PParameterDirection.INOUT);
-
- private final PParameter parameter_event = new PParameter("event", "com.nomagic.uml2.ext.magicdraw.commonbehaviors.mdcommunications.Event", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Event")), PParameterDirection.INOUT);
-
- private final PParameter parameter_effect = new PParameter("effect", "com.nomagic.uml2.ext.magicdraw.activities.mdfundamentalactivities.Activity", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Activity")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_state, parameter_transition, parameter_trigger, parameter_event, parameter_effect);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.loopTransitionWithTriggerEffectEventNoGuard";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("state","transition","trigger","event","effect");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_state = body.getOrCreateVariableByName("state");
- PVariable var_transition = body.getOrCreateVariableByName("transition");
- PVariable var_trigger = body.getOrCreateVariableByName("trigger");
- PVariable var_event = body.getOrCreateVariableByName("event");
- PVariable var_effect = body.getOrCreateVariableByName("effect");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- new TypeConstraint(body, Tuples.flatTupleOf(var_state), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_trigger), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Trigger")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_event), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Event")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_effect), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Activity")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_state, parameter_state),
- new ExportedParameter(body, var_transition, parameter_transition),
- new ExportedParameter(body, var_trigger, parameter_trigger),
- new ExportedParameter(body, var_event, parameter_event),
- new ExportedParameter(body, var_effect, parameter_effect)
- ));
- // Transition.source(transition, state)
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition", "source")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Vertex")));
- new Equality(body, var__virtual_0_, var_state);
- // Transition.target(transition, state)
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition", "target")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Vertex")));
- new Equality(body, var__virtual_1_, var_state);
- // Transition.kind(transition, ::external)
- PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
- new ConstantValue(body, var__virtual_2_, com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.TransitionKindEnum.get("external"));
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition")));
- PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition", "kind")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "TransitionKind")));
- new Equality(body, var__virtual_3_, var__virtual_2_);
- // Transition.trigger(transition, trigger)
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition")));
- PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition", "trigger")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Trigger")));
- new Equality(body, var__virtual_4_, var_trigger);
- // Transition.effect(transition, effect)
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition")));
- PVariable var__virtual_5_ = body.getOrCreateVariableByName(".virtual{5}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_transition, var__virtual_5_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Transition", "effect")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_5_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Behavior")));
- new Equality(body, var__virtual_5_, var_effect);
- // neg find transitionWithGuard(transition, _)
- new NegativePatternCall(body, Tuples.flatTupleOf(var_transition, var___0_), TransitionWithGuard.instance().getInternalQueryRepresentation());
- // Trigger.event(trigger, event)
- new TypeConstraint(body, Tuples.flatTupleOf(var_trigger), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Trigger")));
- PVariable var__virtual_6_ = body.getOrCreateVariableByName(".virtual{6}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_trigger, var__virtual_6_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Trigger", "event")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_6_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Event")));
- new Equality(body, var__virtual_6_, var_event);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NamedElement.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NamedElement.java
deleted file mode 100644
index 1218452..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NamedElement.java
+++ /dev/null
@@ -1,711 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Querying all instances of an EClass with an attribute.
- *
- * pattern namedElement(element : NamedElement, name : java ^java.lang.String) {
- * NamedElement.name(element, name);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class NamedElement extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.namedElement pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement fElement;
-
- private String fName;
-
- private static List parameterNames = makeImmutableList("element", "name");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName) {
- this.fElement = pElement;
- this.fName = pName;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "element": return this.fElement;
- case "name": return this.fName;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fElement;
- case 1: return this.fName;
- default: return null;
- }
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement getElement() {
- return this.fElement;
- }
-
- public String getName() {
- return this.fName;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("element".equals(parameterName) ) {
- this.fElement = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) newValue;
- return true;
- }
- if ("name".equals(parameterName) ) {
- this.fName = (String) newValue;
- return true;
- }
- return false;
- }
-
- public void setElement(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fElement = pElement;
- }
-
- public void setName(final String pName) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fName = pName;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.namedElement";
- }
-
- @Override
- public List parameterNames() {
- return NamedElement.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fElement, fName};
- }
-
- @Override
- public NamedElement.Match toImmutable() {
- return isMutable() ? newMatch(fElement, fName) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"element\"=" + prettyPrintValue(fElement) + ", ");
- result.append("\"name\"=" + prettyPrintValue(fName));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fElement, fName);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof NamedElement.Match)) {
- NamedElement.Match other = (NamedElement.Match) obj;
- return Objects.equals(fElement, other.fElement) && Objects.equals(fName, other.fName);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public NamedElement specification() {
- return NamedElement.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static NamedElement.Match newEmptyMatch() {
- return new Mutable(null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pName the fixed value of pattern parameter name, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static NamedElement.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName) {
- return new Mutable(pElement, pName);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pName the fixed value of pattern parameter name, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static NamedElement.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName) {
- return new Immutable(pElement, pName);
- }
-
- private static final class Mutable extends NamedElement.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName) {
- super(pElement, pName);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends NamedElement.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName) {
- super(pElement, pName);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.namedElement pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Querying all instances of an EClass with an attribute.
- *
- * pattern namedElement(element : NamedElement, name : java ^java.lang.String) {
- * NamedElement.name(element, name);
- * }
- *
- *
- * @see Match
- * @see NamedElement
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static NamedElement.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static NamedElement.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_ELEMENT = 0;
-
- private static final int POSITION_NAME = 1;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NamedElement.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pName the fixed value of pattern parameter name, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName) {
- return rawStreamAllMatches(new Object[]{pElement, pName}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pName the fixed value of pattern parameter name, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName) {
- return rawStreamAllMatches(new Object[]{pElement, pName});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pName the fixed value of pattern parameter name, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName) {
- return rawGetOneArbitraryMatch(new Object[]{pElement, pName});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pName the fixed value of pattern parameter name, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName) {
- return rawHasMatch(new Object[]{pElement, pName});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pName the fixed value of pattern parameter name, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName) {
- return rawCountMatches(new Object[]{pElement, pName});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pName the fixed value of pattern parameter name, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName, final Consumer super NamedElement.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pElement, pName}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pName the fixed value of pattern parameter name, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public NamedElement.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement, final String pName) {
- return NamedElement.Match.newMatch(pElement, pName);
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfelement(final Object[] parameters) {
- return rawStreamAllValues(POSITION_ELEMENT, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelement() {
- return rawStreamAllValuesOfelement(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfelement() {
- return rawStreamAllValuesOfelement(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfelement(final NamedElement.Match partialMatch) {
- return rawStreamAllValuesOfelement(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfelement(final String pName) {
- return rawStreamAllValuesOfelement(new Object[]{null, pName});
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelement(final NamedElement.Match partialMatch) {
- return rawStreamAllValuesOfelement(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelement(final String pName) {
- return rawStreamAllValuesOfelement(new Object[]{null, pName}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for name.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfname(final Object[] parameters) {
- return rawStreamAllValues(POSITION_NAME, parameters).map(String.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for name.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfname() {
- return rawStreamAllValuesOfname(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for name.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfname() {
- return rawStreamAllValuesOfname(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for name.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfname(final NamedElement.Match partialMatch) {
- return rawStreamAllValuesOfname(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for name.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfname(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement) {
- return rawStreamAllValuesOfname(new Object[]{pElement, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for name.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfname(final NamedElement.Match partialMatch) {
- return rawStreamAllValuesOfname(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for name.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfname(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement pElement) {
- return rawStreamAllValuesOfname(new Object[]{pElement, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected NamedElement.Match tupleToMatch(final Tuple t) {
- try {
- return NamedElement.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) t.get(POSITION_ELEMENT), (String) t.get(POSITION_NAME));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NamedElement.Match arrayToMatch(final Object[] match) {
- try {
- return NamedElement.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) match[POSITION_ELEMENT], (String) match[POSITION_NAME]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NamedElement.Match arrayToMatchMutable(final Object[] match) {
- try {
- return NamedElement.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) match[POSITION_ELEMENT], (String) match[POSITION_NAME]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return NamedElement.instance();
- }
- }
-
- private NamedElement() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static NamedElement instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected NamedElement.Matcher instantiate(final ViatraQueryEngine engine) {
- return NamedElement.Matcher.on(engine);
- }
-
- @Override
- public NamedElement.Matcher instantiate() {
- return NamedElement.Matcher.create();
- }
-
- @Override
- public NamedElement.Match newEmptyMatch() {
- return NamedElement.Match.newEmptyMatch();
- }
-
- @Override
- public NamedElement.Match newMatch(final Object... parameters) {
- return NamedElement.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[0], (java.lang.String) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link NamedElement} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link NamedElement#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final NamedElement INSTANCE = new NamedElement();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final NamedElement.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_element = new PParameter("element", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")), PParameterDirection.INOUT);
-
- private final PParameter parameter_name = new PParameter("name", "java.lang.String", new JavaTransitiveInstancesKey(java.lang.String.class), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_element, parameter_name);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.namedElement";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("element","name");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_element = body.getOrCreateVariableByName("element");
- PVariable var_name = body.getOrCreateVariableByName("name");
- new TypeConstraint(body, Tuples.flatTupleOf(var_element), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_name), new JavaTransitiveInstancesKey(java.lang.String.class));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_element, parameter_element),
- new ExportedParameter(body, var_name, parameter_name)
- ));
- // NamedElement.name(element, name)
- new TypeConstraint(body, Tuples.flatTupleOf(var_element), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_element, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement", "name")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "String")));
- new Equality(body, var__virtual_0_, var_name);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NamesOfDependencyEndpoints.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NamesOfDependencyEndpoints.java
deleted file mode 100644
index 07d5239..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NamesOfDependencyEndpoints.java
+++ /dev/null
@@ -1,942 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.Dependencies;
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Reusing the dependency pattern and querying simple attributes.
- *
- * pattern namesOfDependencyEndpoints(source : NamedElement, sourceName : java ^java.lang.String, target : NamedElement, targetName : java ^java.lang.String) {
- * find dependencies(source, target);
- * NamedElement.name(source, sourceName);
- * NamedElement.name(target, targetName);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class NamesOfDependencyEndpoints extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.namesOfDependencyEndpoints pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private NamedElement fSource;
-
- private String fSourceName;
-
- private NamedElement fTarget;
-
- private String fTargetName;
-
- private static List parameterNames = makeImmutableList("source", "sourceName", "target", "targetName");
-
- private Match(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- this.fSource = pSource;
- this.fSourceName = pSourceName;
- this.fTarget = pTarget;
- this.fTargetName = pTargetName;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "source": return this.fSource;
- case "sourceName": return this.fSourceName;
- case "target": return this.fTarget;
- case "targetName": return this.fTargetName;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fSource;
- case 1: return this.fSourceName;
- case 2: return this.fTarget;
- case 3: return this.fTargetName;
- default: return null;
- }
- }
-
- public NamedElement getSource() {
- return this.fSource;
- }
-
- public String getSourceName() {
- return this.fSourceName;
- }
-
- public NamedElement getTarget() {
- return this.fTarget;
- }
-
- public String getTargetName() {
- return this.fTargetName;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("source".equals(parameterName) ) {
- this.fSource = (NamedElement) newValue;
- return true;
- }
- if ("sourceName".equals(parameterName) ) {
- this.fSourceName = (String) newValue;
- return true;
- }
- if ("target".equals(parameterName) ) {
- this.fTarget = (NamedElement) newValue;
- return true;
- }
- if ("targetName".equals(parameterName) ) {
- this.fTargetName = (String) newValue;
- return true;
- }
- return false;
- }
-
- public void setSource(final NamedElement pSource) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fSource = pSource;
- }
-
- public void setSourceName(final String pSourceName) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fSourceName = pSourceName;
- }
-
- public void setTarget(final NamedElement pTarget) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fTarget = pTarget;
- }
-
- public void setTargetName(final String pTargetName) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fTargetName = pTargetName;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.namesOfDependencyEndpoints";
- }
-
- @Override
- public List parameterNames() {
- return NamesOfDependencyEndpoints.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fSource, fSourceName, fTarget, fTargetName};
- }
-
- @Override
- public NamesOfDependencyEndpoints.Match toImmutable() {
- return isMutable() ? newMatch(fSource, fSourceName, fTarget, fTargetName) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"source\"=" + prettyPrintValue(fSource) + ", ");
- result.append("\"sourceName\"=" + prettyPrintValue(fSourceName) + ", ");
- result.append("\"target\"=" + prettyPrintValue(fTarget) + ", ");
- result.append("\"targetName\"=" + prettyPrintValue(fTargetName));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fSource, fSourceName, fTarget, fTargetName);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof NamesOfDependencyEndpoints.Match)) {
- NamesOfDependencyEndpoints.Match other = (NamesOfDependencyEndpoints.Match) obj;
- return Objects.equals(fSource, other.fSource) && Objects.equals(fSourceName, other.fSourceName) && Objects.equals(fTarget, other.fTarget) && Objects.equals(fTargetName, other.fTargetName);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public NamesOfDependencyEndpoints specification() {
- return NamesOfDependencyEndpoints.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static NamesOfDependencyEndpoints.Match newEmptyMatch() {
- return new Mutable(null, null, null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pSourceName the fixed value of pattern parameter sourceName, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param pTargetName the fixed value of pattern parameter targetName, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static NamesOfDependencyEndpoints.Match newMutableMatch(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- return new Mutable(pSource, pSourceName, pTarget, pTargetName);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pSourceName the fixed value of pattern parameter sourceName, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param pTargetName the fixed value of pattern parameter targetName, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static NamesOfDependencyEndpoints.Match newMatch(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- return new Immutable(pSource, pSourceName, pTarget, pTargetName);
- }
-
- private static final class Mutable extends NamesOfDependencyEndpoints.Match {
- Mutable(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- super(pSource, pSourceName, pTarget, pTargetName);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends NamesOfDependencyEndpoints.Match {
- Immutable(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- super(pSource, pSourceName, pTarget, pTargetName);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.namesOfDependencyEndpoints pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Reusing the dependency pattern and querying simple attributes.
- *
- * pattern namesOfDependencyEndpoints(source : NamedElement, sourceName : java ^java.lang.String, target : NamedElement, targetName : java ^java.lang.String) {
- * find dependencies(source, target);
- * NamedElement.name(source, sourceName);
- * NamedElement.name(target, targetName);
- * }
- *
- *
- * @see Match
- * @see NamesOfDependencyEndpoints
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static NamesOfDependencyEndpoints.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static NamesOfDependencyEndpoints.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_SOURCE = 0;
-
- private static final int POSITION_SOURCENAME = 1;
-
- private static final int POSITION_TARGET = 2;
-
- private static final int POSITION_TARGETNAME = 3;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NamesOfDependencyEndpoints.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pSourceName the fixed value of pattern parameter sourceName, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param pTargetName the fixed value of pattern parameter targetName, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- return rawStreamAllMatches(new Object[]{pSource, pSourceName, pTarget, pTargetName}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pSourceName the fixed value of pattern parameter sourceName, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param pTargetName the fixed value of pattern parameter targetName, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- return rawStreamAllMatches(new Object[]{pSource, pSourceName, pTarget, pTargetName});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pSourceName the fixed value of pattern parameter sourceName, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param pTargetName the fixed value of pattern parameter targetName, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- return rawGetOneArbitraryMatch(new Object[]{pSource, pSourceName, pTarget, pTargetName});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pSourceName the fixed value of pattern parameter sourceName, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param pTargetName the fixed value of pattern parameter targetName, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- return rawHasMatch(new Object[]{pSource, pSourceName, pTarget, pTargetName});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pSourceName the fixed value of pattern parameter sourceName, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param pTargetName the fixed value of pattern parameter targetName, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- return rawCountMatches(new Object[]{pSource, pSourceName, pTarget, pTargetName});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pSourceName the fixed value of pattern parameter sourceName, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param pTargetName the fixed value of pattern parameter targetName, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName, final Consumer super NamesOfDependencyEndpoints.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pSource, pSourceName, pTarget, pTargetName}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pSource the fixed value of pattern parameter source, or null if not bound.
- * @param pSourceName the fixed value of pattern parameter sourceName, or null if not bound.
- * @param pTarget the fixed value of pattern parameter target, or null if not bound.
- * @param pTargetName the fixed value of pattern parameter targetName, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public NamesOfDependencyEndpoints.Match newMatch(final NamedElement pSource, final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- return NamesOfDependencyEndpoints.Match.newMatch(pSource, pSourceName, pTarget, pTargetName);
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfsource(final Object[] parameters) {
- return rawStreamAllValues(POSITION_SOURCE, parameters).map(NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource() {
- return rawStreamAllValuesOfsource(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource() {
- return rawStreamAllValuesOfsource(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource(final NamesOfDependencyEndpoints.Match partialMatch) {
- return rawStreamAllValuesOfsource(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsource(final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- return rawStreamAllValuesOfsource(new Object[]{null, pSourceName, pTarget, pTargetName});
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource(final NamesOfDependencyEndpoints.Match partialMatch) {
- return rawStreamAllValuesOfsource(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for source.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsource(final String pSourceName, final NamedElement pTarget, final String pTargetName) {
- return rawStreamAllValuesOfsource(new Object[]{null, pSourceName, pTarget, pTargetName}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for sourceName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfsourceName(final Object[] parameters) {
- return rawStreamAllValues(POSITION_SOURCENAME, parameters).map(String.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for sourceName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsourceName() {
- return rawStreamAllValuesOfsourceName(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for sourceName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsourceName() {
- return rawStreamAllValuesOfsourceName(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for sourceName.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsourceName(final NamesOfDependencyEndpoints.Match partialMatch) {
- return rawStreamAllValuesOfsourceName(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for sourceName.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsourceName(final NamedElement pSource, final NamedElement pTarget, final String pTargetName) {
- return rawStreamAllValuesOfsourceName(new Object[]{pSource, null, pTarget, pTargetName});
- }
-
- /**
- * Retrieve the set of values that occur in matches for sourceName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsourceName(final NamesOfDependencyEndpoints.Match partialMatch) {
- return rawStreamAllValuesOfsourceName(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for sourceName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsourceName(final NamedElement pSource, final NamedElement pTarget, final String pTargetName) {
- return rawStreamAllValuesOfsourceName(new Object[]{pSource, null, pTarget, pTargetName}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOftarget(final Object[] parameters) {
- return rawStreamAllValues(POSITION_TARGET, parameters).map(NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget() {
- return rawStreamAllValuesOftarget(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget() {
- return rawStreamAllValuesOftarget(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget(final NamesOfDependencyEndpoints.Match partialMatch) {
- return rawStreamAllValuesOftarget(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftarget(final NamedElement pSource, final String pSourceName, final String pTargetName) {
- return rawStreamAllValuesOftarget(new Object[]{pSource, pSourceName, null, pTargetName});
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget(final NamesOfDependencyEndpoints.Match partialMatch) {
- return rawStreamAllValuesOftarget(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for target.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftarget(final NamedElement pSource, final String pSourceName, final String pTargetName) {
- return rawStreamAllValuesOftarget(new Object[]{pSource, pSourceName, null, pTargetName}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOftargetName(final Object[] parameters) {
- return rawStreamAllValues(POSITION_TARGETNAME, parameters).map(String.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftargetName() {
- return rawStreamAllValuesOftargetName(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftargetName() {
- return rawStreamAllValuesOftargetName(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetName.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftargetName(final NamesOfDependencyEndpoints.Match partialMatch) {
- return rawStreamAllValuesOftargetName(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetName.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftargetName(final NamedElement pSource, final String pSourceName, final NamedElement pTarget) {
- return rawStreamAllValuesOftargetName(new Object[]{pSource, pSourceName, pTarget, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftargetName(final NamesOfDependencyEndpoints.Match partialMatch) {
- return rawStreamAllValuesOftargetName(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for targetName.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftargetName(final NamedElement pSource, final String pSourceName, final NamedElement pTarget) {
- return rawStreamAllValuesOftargetName(new Object[]{pSource, pSourceName, pTarget, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected NamesOfDependencyEndpoints.Match tupleToMatch(final Tuple t) {
- try {
- return NamesOfDependencyEndpoints.Match.newMatch((NamedElement) t.get(POSITION_SOURCE), (String) t.get(POSITION_SOURCENAME), (NamedElement) t.get(POSITION_TARGET), (String) t.get(POSITION_TARGETNAME));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NamesOfDependencyEndpoints.Match arrayToMatch(final Object[] match) {
- try {
- return NamesOfDependencyEndpoints.Match.newMatch((NamedElement) match[POSITION_SOURCE], (String) match[POSITION_SOURCENAME], (NamedElement) match[POSITION_TARGET], (String) match[POSITION_TARGETNAME]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NamesOfDependencyEndpoints.Match arrayToMatchMutable(final Object[] match) {
- try {
- return NamesOfDependencyEndpoints.Match.newMutableMatch((NamedElement) match[POSITION_SOURCE], (String) match[POSITION_SOURCENAME], (NamedElement) match[POSITION_TARGET], (String) match[POSITION_TARGETNAME]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return NamesOfDependencyEndpoints.instance();
- }
- }
-
- private NamesOfDependencyEndpoints() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static NamesOfDependencyEndpoints instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected NamesOfDependencyEndpoints.Matcher instantiate(final ViatraQueryEngine engine) {
- return NamesOfDependencyEndpoints.Matcher.on(engine);
- }
-
- @Override
- public NamesOfDependencyEndpoints.Matcher instantiate() {
- return NamesOfDependencyEndpoints.Matcher.create();
- }
-
- @Override
- public NamesOfDependencyEndpoints.Match newEmptyMatch() {
- return NamesOfDependencyEndpoints.Match.newEmptyMatch();
- }
-
- @Override
- public NamesOfDependencyEndpoints.Match newMatch(final Object... parameters) {
- return NamesOfDependencyEndpoints.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[0], (java.lang.String) parameters[1], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[2], (java.lang.String) parameters[3]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link NamesOfDependencyEndpoints} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link NamesOfDependencyEndpoints#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final NamesOfDependencyEndpoints INSTANCE = new NamesOfDependencyEndpoints();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final NamesOfDependencyEndpoints.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_source = new PParameter("source", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")), PParameterDirection.INOUT);
-
- private final PParameter parameter_sourceName = new PParameter("sourceName", "java.lang.String", new JavaTransitiveInstancesKey(java.lang.String.class), PParameterDirection.INOUT);
-
- private final PParameter parameter_target = new PParameter("target", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")), PParameterDirection.INOUT);
-
- private final PParameter parameter_targetName = new PParameter("targetName", "java.lang.String", new JavaTransitiveInstancesKey(java.lang.String.class), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_source, parameter_sourceName, parameter_target, parameter_targetName);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.namesOfDependencyEndpoints";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("source","sourceName","target","targetName");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_source = body.getOrCreateVariableByName("source");
- PVariable var_sourceName = body.getOrCreateVariableByName("sourceName");
- PVariable var_target = body.getOrCreateVariableByName("target");
- PVariable var_targetName = body.getOrCreateVariableByName("targetName");
- new TypeConstraint(body, Tuples.flatTupleOf(var_source), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_sourceName), new JavaTransitiveInstancesKey(java.lang.String.class));
- new TypeConstraint(body, Tuples.flatTupleOf(var_target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_targetName), new JavaTransitiveInstancesKey(java.lang.String.class));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_source, parameter_source),
- new ExportedParameter(body, var_sourceName, parameter_sourceName),
- new ExportedParameter(body, var_target, parameter_target),
- new ExportedParameter(body, var_targetName, parameter_targetName)
- ));
- // find dependencies(source, target)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_source, var_target), Dependencies.instance().getInternalQueryRepresentation());
- // NamedElement.name(source, sourceName)
- new TypeConstraint(body, Tuples.flatTupleOf(var_source), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_source, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement", "name")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "String")));
- new Equality(body, var__virtual_0_, var_sourceName);
- // NamedElement.name(target, targetName)
- new TypeConstraint(body, Tuples.flatTupleOf(var_target), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_target, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement", "name")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "String")));
- new Equality(body, var__virtual_1_, var_targetName);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NonBlockClasses.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NonBlockClasses.java
deleted file mode 100644
index 919b07a..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NonBlockClasses.java
+++ /dev/null
@@ -1,549 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.Blocks;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Querying elements that are not the specified type: single negation.
- *
- * pattern nonBlockClasses(class : Class) {
- * neg find blocks(class);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class NonBlockClasses extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.nonBlockClasses pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class fClass;
-
- private static List parameterNames = makeImmutableList("class");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- this.fClass = pClass;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "class": return this.fClass;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fClass;
- default: return null;
- }
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getValueOfClass() {
- return this.fClass;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("class".equals(parameterName) ) {
- this.fClass = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- return false;
- }
-
- public void setClass(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass = pClass;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.nonBlockClasses";
- }
-
- @Override
- public List parameterNames() {
- return NonBlockClasses.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass};
- }
-
- @Override
- public NonBlockClasses.Match toImmutable() {
- return isMutable() ? newMatch(fClass) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof NonBlockClasses.Match)) {
- NonBlockClasses.Match other = (NonBlockClasses.Match) obj;
- return Objects.equals(fClass, other.fClass);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public NonBlockClasses specification() {
- return NonBlockClasses.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static NonBlockClasses.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static NonBlockClasses.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Mutable(pClass);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static NonBlockClasses.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Immutable(pClass);
- }
-
- private static final class Mutable extends NonBlockClasses.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends NonBlockClasses.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.nonBlockClasses pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Querying elements that are not the specified type: single negation.
- *
- * pattern nonBlockClasses(class : Class) {
- * neg find blocks(class);
- * }
- *
- *
- * @see Match
- * @see NonBlockClasses
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static NonBlockClasses.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static NonBlockClasses.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_CLASS = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NonBlockClasses.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawGetOneArbitraryMatch(new Object[]{pClass});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawHasMatch(new Object[]{pClass});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawCountMatches(new Object[]{pClass});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Consumer super NonBlockClasses.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public NonBlockClasses.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return NonBlockClasses.Match.newMatch(pClass);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfclass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_CLASS, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray());
- }
-
- @Override
- protected NonBlockClasses.Match tupleToMatch(final Tuple t) {
- try {
- return NonBlockClasses.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_CLASS));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NonBlockClasses.Match arrayToMatch(final Object[] match) {
- try {
- return NonBlockClasses.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NonBlockClasses.Match arrayToMatchMutable(final Object[] match) {
- try {
- return NonBlockClasses.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return NonBlockClasses.instance();
- }
- }
-
- private NonBlockClasses() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static NonBlockClasses instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected NonBlockClasses.Matcher instantiate(final ViatraQueryEngine engine) {
- return NonBlockClasses.Matcher.on(engine);
- }
-
- @Override
- public NonBlockClasses.Matcher instantiate() {
- return NonBlockClasses.Matcher.create();
- }
-
- @Override
- public NonBlockClasses.Match newEmptyMatch() {
- return NonBlockClasses.Match.newEmptyMatch();
- }
-
- @Override
- public NonBlockClasses.Match newMatch(final Object... parameters) {
- return NonBlockClasses.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link NonBlockClasses} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link NonBlockClasses#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final NonBlockClasses INSTANCE = new NonBlockClasses();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final NonBlockClasses.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_class = new PParameter("class", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.nonBlockClasses";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_class = body.getOrCreateVariableByName("class");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class)
- ));
- // neg find blocks(class)
- new NegativePatternCall(body, Tuples.flatTupleOf(var_class), Blocks.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NumberOfSubregions.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NumberOfSubregions.java
deleted file mode 100644
index d107163..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NumberOfSubregions.java
+++ /dev/null
@@ -1,710 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.Subregions;
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Reusing a simple pattern with the "count" aggregator.
- *
- * pattern numberOfSubregions(state : State, regionCount : java ^java.lang.Integer) {
- * regionCount == count find subregions(state, _subregion);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class NumberOfSubregions extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.numberOfSubregions pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private State fState;
-
- private Integer fRegionCount;
-
- private static List parameterNames = makeImmutableList("state", "regionCount");
-
- private Match(final State pState, final Integer pRegionCount) {
- this.fState = pState;
- this.fRegionCount = pRegionCount;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "state": return this.fState;
- case "regionCount": return this.fRegionCount;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fState;
- case 1: return this.fRegionCount;
- default: return null;
- }
- }
-
- public State getState() {
- return this.fState;
- }
-
- public Integer getRegionCount() {
- return this.fRegionCount;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("state".equals(parameterName) ) {
- this.fState = (State) newValue;
- return true;
- }
- if ("regionCount".equals(parameterName) ) {
- this.fRegionCount = (Integer) newValue;
- return true;
- }
- return false;
- }
-
- public void setState(final State pState) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fState = pState;
- }
-
- public void setRegionCount(final Integer pRegionCount) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fRegionCount = pRegionCount;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.numberOfSubregions";
- }
-
- @Override
- public List parameterNames() {
- return NumberOfSubregions.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fState, fRegionCount};
- }
-
- @Override
- public NumberOfSubregions.Match toImmutable() {
- return isMutable() ? newMatch(fState, fRegionCount) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"state\"=" + prettyPrintValue(fState) + ", ");
- result.append("\"regionCount\"=" + prettyPrintValue(fRegionCount));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fState, fRegionCount);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof NumberOfSubregions.Match)) {
- NumberOfSubregions.Match other = (NumberOfSubregions.Match) obj;
- return Objects.equals(fState, other.fState) && Objects.equals(fRegionCount, other.fRegionCount);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public NumberOfSubregions specification() {
- return NumberOfSubregions.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static NumberOfSubregions.Match newEmptyMatch() {
- return new Mutable(null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pRegionCount the fixed value of pattern parameter regionCount, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static NumberOfSubregions.Match newMutableMatch(final State pState, final Integer pRegionCount) {
- return new Mutable(pState, pRegionCount);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pRegionCount the fixed value of pattern parameter regionCount, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static NumberOfSubregions.Match newMatch(final State pState, final Integer pRegionCount) {
- return new Immutable(pState, pRegionCount);
- }
-
- private static final class Mutable extends NumberOfSubregions.Match {
- Mutable(final State pState, final Integer pRegionCount) {
- super(pState, pRegionCount);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends NumberOfSubregions.Match {
- Immutable(final State pState, final Integer pRegionCount) {
- super(pState, pRegionCount);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.numberOfSubregions pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Reusing a simple pattern with the "count" aggregator.
- *
- * pattern numberOfSubregions(state : State, regionCount : java ^java.lang.Integer) {
- * regionCount == count find subregions(state, _subregion);
- * }
- *
- *
- * @see Match
- * @see NumberOfSubregions
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static NumberOfSubregions.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static NumberOfSubregions.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_STATE = 0;
-
- private static final int POSITION_REGIONCOUNT = 1;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NumberOfSubregions.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pRegionCount the fixed value of pattern parameter regionCount, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final State pState, final Integer pRegionCount) {
- return rawStreamAllMatches(new Object[]{pState, pRegionCount}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pRegionCount the fixed value of pattern parameter regionCount, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final State pState, final Integer pRegionCount) {
- return rawStreamAllMatches(new Object[]{pState, pRegionCount});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pRegionCount the fixed value of pattern parameter regionCount, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final State pState, final Integer pRegionCount) {
- return rawGetOneArbitraryMatch(new Object[]{pState, pRegionCount});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pRegionCount the fixed value of pattern parameter regionCount, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final State pState, final Integer pRegionCount) {
- return rawHasMatch(new Object[]{pState, pRegionCount});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pRegionCount the fixed value of pattern parameter regionCount, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final State pState, final Integer pRegionCount) {
- return rawCountMatches(new Object[]{pState, pRegionCount});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pRegionCount the fixed value of pattern parameter regionCount, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final State pState, final Integer pRegionCount, final Consumer super NumberOfSubregions.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pState, pRegionCount}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pRegionCount the fixed value of pattern parameter regionCount, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public NumberOfSubregions.Match newMatch(final State pState, final Integer pRegionCount) {
- return NumberOfSubregions.Match.newMatch(pState, pRegionCount);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfstate(final Object[] parameters) {
- return rawStreamAllValues(POSITION_STATE, parameters).map(State.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate(final NumberOfSubregions.Match partialMatch) {
- return rawStreamAllValuesOfstate(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate(final Integer pRegionCount) {
- return rawStreamAllValuesOfstate(new Object[]{null, pRegionCount});
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate(final NumberOfSubregions.Match partialMatch) {
- return rawStreamAllValuesOfstate(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate(final Integer pRegionCount) {
- return rawStreamAllValuesOfstate(new Object[]{null, pRegionCount}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for regionCount.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfregionCount(final Object[] parameters) {
- return rawStreamAllValues(POSITION_REGIONCOUNT, parameters).map(Integer.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for regionCount.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfregionCount() {
- return rawStreamAllValuesOfregionCount(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for regionCount.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfregionCount() {
- return rawStreamAllValuesOfregionCount(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for regionCount.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfregionCount(final NumberOfSubregions.Match partialMatch) {
- return rawStreamAllValuesOfregionCount(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for regionCount.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfregionCount(final State pState) {
- return rawStreamAllValuesOfregionCount(new Object[]{pState, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for regionCount.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfregionCount(final NumberOfSubregions.Match partialMatch) {
- return rawStreamAllValuesOfregionCount(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for regionCount.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfregionCount(final State pState) {
- return rawStreamAllValuesOfregionCount(new Object[]{pState, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected NumberOfSubregions.Match tupleToMatch(final Tuple t) {
- try {
- return NumberOfSubregions.Match.newMatch((State) t.get(POSITION_STATE), (Integer) t.get(POSITION_REGIONCOUNT));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NumberOfSubregions.Match arrayToMatch(final Object[] match) {
- try {
- return NumberOfSubregions.Match.newMatch((State) match[POSITION_STATE], (Integer) match[POSITION_REGIONCOUNT]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NumberOfSubregions.Match arrayToMatchMutable(final Object[] match) {
- try {
- return NumberOfSubregions.Match.newMutableMatch((State) match[POSITION_STATE], (Integer) match[POSITION_REGIONCOUNT]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return NumberOfSubregions.instance();
- }
- }
-
- private NumberOfSubregions() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static NumberOfSubregions instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected NumberOfSubregions.Matcher instantiate(final ViatraQueryEngine engine) {
- return NumberOfSubregions.Matcher.on(engine);
- }
-
- @Override
- public NumberOfSubregions.Matcher instantiate() {
- return NumberOfSubregions.Matcher.create();
- }
-
- @Override
- public NumberOfSubregions.Match newEmptyMatch() {
- return NumberOfSubregions.Match.newEmptyMatch();
- }
-
- @Override
- public NumberOfSubregions.Match newMatch(final Object... parameters) {
- return NumberOfSubregions.Match.newMatch((com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State) parameters[0], (java.lang.Integer) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link NumberOfSubregions} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link NumberOfSubregions#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final NumberOfSubregions INSTANCE = new NumberOfSubregions();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final NumberOfSubregions.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_state = new PParameter("state", "com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")), PParameterDirection.INOUT);
-
- private final PParameter parameter_regionCount = new PParameter("regionCount", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_state, parameter_regionCount);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.numberOfSubregions";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("state","regionCount");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_state = body.getOrCreateVariableByName("state");
- PVariable var_regionCount = body.getOrCreateVariableByName("regionCount");
- PVariable var__subregion = body.getOrCreateVariableByName("_subregion");
- new TypeConstraint(body, Tuples.flatTupleOf(var_state), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")));
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_regionCount), new JavaTransitiveInstancesKey(java.lang.Integer.class));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_state, parameter_state),
- new ExportedParameter(body, var_regionCount, parameter_regionCount)
- ));
- // regionCount == count find subregions(state, _subregion)
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new PatternMatchCounter(body, Tuples.flatTupleOf(var_state, var__subregion), Subregions.instance().getInternalQueryRepresentation(), var__virtual_0_);
- new Equality(body, var_regionCount, var__virtual_0_);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NumberOfTransitiveSubstates.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NumberOfTransitiveSubstates.java
deleted file mode 100644
index cb9240a..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/NumberOfTransitiveSubstates.java
+++ /dev/null
@@ -1,710 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.TransitiveSubstates;
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Reusing a transitive closure pattern with the count aggregator.
- *
- * pattern numberOfTransitiveSubstates(state : State, transitiveSubstateCount : java ^java.lang.Integer) {
- * transitiveSubstateCount == count find transitiveSubstates(state, _);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class NumberOfTransitiveSubstates extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.numberOfTransitiveSubstates pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private State fState;
-
- private Integer fTransitiveSubstateCount;
-
- private static List parameterNames = makeImmutableList("state", "transitiveSubstateCount");
-
- private Match(final State pState, final Integer pTransitiveSubstateCount) {
- this.fState = pState;
- this.fTransitiveSubstateCount = pTransitiveSubstateCount;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "state": return this.fState;
- case "transitiveSubstateCount": return this.fTransitiveSubstateCount;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fState;
- case 1: return this.fTransitiveSubstateCount;
- default: return null;
- }
- }
-
- public State getState() {
- return this.fState;
- }
-
- public Integer getTransitiveSubstateCount() {
- return this.fTransitiveSubstateCount;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("state".equals(parameterName) ) {
- this.fState = (State) newValue;
- return true;
- }
- if ("transitiveSubstateCount".equals(parameterName) ) {
- this.fTransitiveSubstateCount = (Integer) newValue;
- return true;
- }
- return false;
- }
-
- public void setState(final State pState) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fState = pState;
- }
-
- public void setTransitiveSubstateCount(final Integer pTransitiveSubstateCount) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fTransitiveSubstateCount = pTransitiveSubstateCount;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.numberOfTransitiveSubstates";
- }
-
- @Override
- public List parameterNames() {
- return NumberOfTransitiveSubstates.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fState, fTransitiveSubstateCount};
- }
-
- @Override
- public NumberOfTransitiveSubstates.Match toImmutable() {
- return isMutable() ? newMatch(fState, fTransitiveSubstateCount) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"state\"=" + prettyPrintValue(fState) + ", ");
- result.append("\"transitiveSubstateCount\"=" + prettyPrintValue(fTransitiveSubstateCount));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fState, fTransitiveSubstateCount);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof NumberOfTransitiveSubstates.Match)) {
- NumberOfTransitiveSubstates.Match other = (NumberOfTransitiveSubstates.Match) obj;
- return Objects.equals(fState, other.fState) && Objects.equals(fTransitiveSubstateCount, other.fTransitiveSubstateCount);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public NumberOfTransitiveSubstates specification() {
- return NumberOfTransitiveSubstates.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static NumberOfTransitiveSubstates.Match newEmptyMatch() {
- return new Mutable(null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransitiveSubstateCount the fixed value of pattern parameter transitiveSubstateCount, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static NumberOfTransitiveSubstates.Match newMutableMatch(final State pState, final Integer pTransitiveSubstateCount) {
- return new Mutable(pState, pTransitiveSubstateCount);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransitiveSubstateCount the fixed value of pattern parameter transitiveSubstateCount, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static NumberOfTransitiveSubstates.Match newMatch(final State pState, final Integer pTransitiveSubstateCount) {
- return new Immutable(pState, pTransitiveSubstateCount);
- }
-
- private static final class Mutable extends NumberOfTransitiveSubstates.Match {
- Mutable(final State pState, final Integer pTransitiveSubstateCount) {
- super(pState, pTransitiveSubstateCount);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends NumberOfTransitiveSubstates.Match {
- Immutable(final State pState, final Integer pTransitiveSubstateCount) {
- super(pState, pTransitiveSubstateCount);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.numberOfTransitiveSubstates pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Reusing a transitive closure pattern with the count aggregator.
- *
- * pattern numberOfTransitiveSubstates(state : State, transitiveSubstateCount : java ^java.lang.Integer) {
- * transitiveSubstateCount == count find transitiveSubstates(state, _);
- * }
- *
- *
- * @see Match
- * @see NumberOfTransitiveSubstates
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static NumberOfTransitiveSubstates.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static NumberOfTransitiveSubstates.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_STATE = 0;
-
- private static final int POSITION_TRANSITIVESUBSTATECOUNT = 1;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NumberOfTransitiveSubstates.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransitiveSubstateCount the fixed value of pattern parameter transitiveSubstateCount, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final State pState, final Integer pTransitiveSubstateCount) {
- return rawStreamAllMatches(new Object[]{pState, pTransitiveSubstateCount}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransitiveSubstateCount the fixed value of pattern parameter transitiveSubstateCount, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final State pState, final Integer pTransitiveSubstateCount) {
- return rawStreamAllMatches(new Object[]{pState, pTransitiveSubstateCount});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransitiveSubstateCount the fixed value of pattern parameter transitiveSubstateCount, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final State pState, final Integer pTransitiveSubstateCount) {
- return rawGetOneArbitraryMatch(new Object[]{pState, pTransitiveSubstateCount});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransitiveSubstateCount the fixed value of pattern parameter transitiveSubstateCount, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final State pState, final Integer pTransitiveSubstateCount) {
- return rawHasMatch(new Object[]{pState, pTransitiveSubstateCount});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransitiveSubstateCount the fixed value of pattern parameter transitiveSubstateCount, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final State pState, final Integer pTransitiveSubstateCount) {
- return rawCountMatches(new Object[]{pState, pTransitiveSubstateCount});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransitiveSubstateCount the fixed value of pattern parameter transitiveSubstateCount, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final State pState, final Integer pTransitiveSubstateCount, final Consumer super NumberOfTransitiveSubstates.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pState, pTransitiveSubstateCount}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pTransitiveSubstateCount the fixed value of pattern parameter transitiveSubstateCount, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public NumberOfTransitiveSubstates.Match newMatch(final State pState, final Integer pTransitiveSubstateCount) {
- return NumberOfTransitiveSubstates.Match.newMatch(pState, pTransitiveSubstateCount);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfstate(final Object[] parameters) {
- return rawStreamAllValues(POSITION_STATE, parameters).map(State.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate(final NumberOfTransitiveSubstates.Match partialMatch) {
- return rawStreamAllValuesOfstate(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate(final Integer pTransitiveSubstateCount) {
- return rawStreamAllValuesOfstate(new Object[]{null, pTransitiveSubstateCount});
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate(final NumberOfTransitiveSubstates.Match partialMatch) {
- return rawStreamAllValuesOfstate(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate(final Integer pTransitiveSubstateCount) {
- return rawStreamAllValuesOfstate(new Object[]{null, pTransitiveSubstateCount}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transitiveSubstateCount.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOftransitiveSubstateCount(final Object[] parameters) {
- return rawStreamAllValues(POSITION_TRANSITIVESUBSTATECOUNT, parameters).map(Integer.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for transitiveSubstateCount.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftransitiveSubstateCount() {
- return rawStreamAllValuesOftransitiveSubstateCount(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transitiveSubstateCount.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftransitiveSubstateCount() {
- return rawStreamAllValuesOftransitiveSubstateCount(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transitiveSubstateCount.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftransitiveSubstateCount(final NumberOfTransitiveSubstates.Match partialMatch) {
- return rawStreamAllValuesOftransitiveSubstateCount(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transitiveSubstateCount.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOftransitiveSubstateCount(final State pState) {
- return rawStreamAllValuesOftransitiveSubstateCount(new Object[]{pState, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for transitiveSubstateCount.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftransitiveSubstateCount(final NumberOfTransitiveSubstates.Match partialMatch) {
- return rawStreamAllValuesOftransitiveSubstateCount(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for transitiveSubstateCount.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOftransitiveSubstateCount(final State pState) {
- return rawStreamAllValuesOftransitiveSubstateCount(new Object[]{pState, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected NumberOfTransitiveSubstates.Match tupleToMatch(final Tuple t) {
- try {
- return NumberOfTransitiveSubstates.Match.newMatch((State) t.get(POSITION_STATE), (Integer) t.get(POSITION_TRANSITIVESUBSTATECOUNT));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NumberOfTransitiveSubstates.Match arrayToMatch(final Object[] match) {
- try {
- return NumberOfTransitiveSubstates.Match.newMatch((State) match[POSITION_STATE], (Integer) match[POSITION_TRANSITIVESUBSTATECOUNT]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NumberOfTransitiveSubstates.Match arrayToMatchMutable(final Object[] match) {
- try {
- return NumberOfTransitiveSubstates.Match.newMutableMatch((State) match[POSITION_STATE], (Integer) match[POSITION_TRANSITIVESUBSTATECOUNT]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return NumberOfTransitiveSubstates.instance();
- }
- }
-
- private NumberOfTransitiveSubstates() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static NumberOfTransitiveSubstates instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected NumberOfTransitiveSubstates.Matcher instantiate(final ViatraQueryEngine engine) {
- return NumberOfTransitiveSubstates.Matcher.on(engine);
- }
-
- @Override
- public NumberOfTransitiveSubstates.Matcher instantiate() {
- return NumberOfTransitiveSubstates.Matcher.create();
- }
-
- @Override
- public NumberOfTransitiveSubstates.Match newEmptyMatch() {
- return NumberOfTransitiveSubstates.Match.newEmptyMatch();
- }
-
- @Override
- public NumberOfTransitiveSubstates.Match newMatch(final Object... parameters) {
- return NumberOfTransitiveSubstates.Match.newMatch((com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State) parameters[0], (java.lang.Integer) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link NumberOfTransitiveSubstates} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link NumberOfTransitiveSubstates#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final NumberOfTransitiveSubstates INSTANCE = new NumberOfTransitiveSubstates();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final NumberOfTransitiveSubstates.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_state = new PParameter("state", "com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")), PParameterDirection.INOUT);
-
- private final PParameter parameter_transitiveSubstateCount = new PParameter("transitiveSubstateCount", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_state, parameter_transitiveSubstateCount);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.numberOfTransitiveSubstates";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("state","transitiveSubstateCount");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_state = body.getOrCreateVariableByName("state");
- PVariable var_transitiveSubstateCount = body.getOrCreateVariableByName("transitiveSubstateCount");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- new TypeConstraint(body, Tuples.flatTupleOf(var_state), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")));
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_transitiveSubstateCount), new JavaTransitiveInstancesKey(java.lang.Integer.class));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_state, parameter_state),
- new ExportedParameter(body, var_transitiveSubstateCount, parameter_transitiveSubstateCount)
- ));
- // transitiveSubstateCount == count find transitiveSubstates(state, _)
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new PatternMatchCounter(body, Tuples.flatTupleOf(var_state, var___0_), TransitiveSubstates.instance().getInternalQueryRepresentation(), var__virtual_0_);
- new Equality(body, var_transitiveSubstateCount, var__virtual_0_);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/ParentState.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/ParentState.java
deleted file mode 100644
index 07958a9..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/ParentState.java
+++ /dev/null
@@ -1,717 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Simple pattern for transitive closures.
- *
- * pattern parentState(state : State, parentState : State) {
- * State.region(parentState, subregion);
- * Region.subvertex(subregion, state);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class ParentState extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.parentState pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private State fState;
-
- private State fParentState;
-
- private static List parameterNames = makeImmutableList("state", "parentState");
-
- private Match(final State pState, final State pParentState) {
- this.fState = pState;
- this.fParentState = pParentState;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "state": return this.fState;
- case "parentState": return this.fParentState;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fState;
- case 1: return this.fParentState;
- default: return null;
- }
- }
-
- public State getState() {
- return this.fState;
- }
-
- public State getParentState() {
- return this.fParentState;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("state".equals(parameterName) ) {
- this.fState = (State) newValue;
- return true;
- }
- if ("parentState".equals(parameterName) ) {
- this.fParentState = (State) newValue;
- return true;
- }
- return false;
- }
-
- public void setState(final State pState) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fState = pState;
- }
-
- public void setParentState(final State pParentState) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fParentState = pParentState;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.parentState";
- }
-
- @Override
- public List parameterNames() {
- return ParentState.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fState, fParentState};
- }
-
- @Override
- public ParentState.Match toImmutable() {
- return isMutable() ? newMatch(fState, fParentState) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"state\"=" + prettyPrintValue(fState) + ", ");
- result.append("\"parentState\"=" + prettyPrintValue(fParentState));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fState, fParentState);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof ParentState.Match)) {
- ParentState.Match other = (ParentState.Match) obj;
- return Objects.equals(fState, other.fState) && Objects.equals(fParentState, other.fParentState);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public ParentState specification() {
- return ParentState.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static ParentState.Match newEmptyMatch() {
- return new Mutable(null, null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pParentState the fixed value of pattern parameter parentState, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static ParentState.Match newMutableMatch(final State pState, final State pParentState) {
- return new Mutable(pState, pParentState);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pParentState the fixed value of pattern parameter parentState, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static ParentState.Match newMatch(final State pState, final State pParentState) {
- return new Immutable(pState, pParentState);
- }
-
- private static final class Mutable extends ParentState.Match {
- Mutable(final State pState, final State pParentState) {
- super(pState, pParentState);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends ParentState.Match {
- Immutable(final State pState, final State pParentState) {
- super(pState, pParentState);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.parentState pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Simple pattern for transitive closures.
- *
- * pattern parentState(state : State, parentState : State) {
- * State.region(parentState, subregion);
- * Region.subvertex(subregion, state);
- * }
- *
- *
- * @see Match
- * @see ParentState
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static ParentState.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static ParentState.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_STATE = 0;
-
- private static final int POSITION_PARENTSTATE = 1;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ParentState.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pParentState the fixed value of pattern parameter parentState, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final State pState, final State pParentState) {
- return rawStreamAllMatches(new Object[]{pState, pParentState}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pParentState the fixed value of pattern parameter parentState, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final State pState, final State pParentState) {
- return rawStreamAllMatches(new Object[]{pState, pParentState});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pParentState the fixed value of pattern parameter parentState, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final State pState, final State pParentState) {
- return rawGetOneArbitraryMatch(new Object[]{pState, pParentState});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pParentState the fixed value of pattern parameter parentState, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final State pState, final State pParentState) {
- return rawHasMatch(new Object[]{pState, pParentState});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pParentState the fixed value of pattern parameter parentState, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final State pState, final State pParentState) {
- return rawCountMatches(new Object[]{pState, pParentState});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pParentState the fixed value of pattern parameter parentState, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final State pState, final State pParentState, final Consumer super ParentState.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pState, pParentState}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param pParentState the fixed value of pattern parameter parentState, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public ParentState.Match newMatch(final State pState, final State pParentState) {
- return ParentState.Match.newMatch(pState, pParentState);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfstate(final Object[] parameters) {
- return rawStreamAllValues(POSITION_STATE, parameters).map(State.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate(final ParentState.Match partialMatch) {
- return rawStreamAllValuesOfstate(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate(final State pParentState) {
- return rawStreamAllValuesOfstate(new Object[]{null, pParentState});
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate(final ParentState.Match partialMatch) {
- return rawStreamAllValuesOfstate(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate(final State pParentState) {
- return rawStreamAllValuesOfstate(new Object[]{null, pParentState}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for parentState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfparentState(final Object[] parameters) {
- return rawStreamAllValues(POSITION_PARENTSTATE, parameters).map(State.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for parentState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfparentState() {
- return rawStreamAllValuesOfparentState(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for parentState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfparentState() {
- return rawStreamAllValuesOfparentState(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for parentState.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfparentState(final ParentState.Match partialMatch) {
- return rawStreamAllValuesOfparentState(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for parentState.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- *
- * @return the Stream of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfparentState(final State pState) {
- return rawStreamAllValuesOfparentState(new Object[]{pState, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for parentState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfparentState(final ParentState.Match partialMatch) {
- return rawStreamAllValuesOfparentState(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for parentState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfparentState(final State pState) {
- return rawStreamAllValuesOfparentState(new Object[]{pState, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected ParentState.Match tupleToMatch(final Tuple t) {
- try {
- return ParentState.Match.newMatch((State) t.get(POSITION_STATE), (State) t.get(POSITION_PARENTSTATE));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ParentState.Match arrayToMatch(final Object[] match) {
- try {
- return ParentState.Match.newMatch((State) match[POSITION_STATE], (State) match[POSITION_PARENTSTATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ParentState.Match arrayToMatchMutable(final Object[] match) {
- try {
- return ParentState.Match.newMutableMatch((State) match[POSITION_STATE], (State) match[POSITION_PARENTSTATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return ParentState.instance();
- }
- }
-
- private ParentState() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ParentState instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected ParentState.Matcher instantiate(final ViatraQueryEngine engine) {
- return ParentState.Matcher.on(engine);
- }
-
- @Override
- public ParentState.Matcher instantiate() {
- return ParentState.Matcher.create();
- }
-
- @Override
- public ParentState.Match newEmptyMatch() {
- return ParentState.Match.newEmptyMatch();
- }
-
- @Override
- public ParentState.Match newMatch(final Object... parameters) {
- return ParentState.Match.newMatch((com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State) parameters[0], (com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link ParentState} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link ParentState#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final ParentState INSTANCE = new ParentState();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final ParentState.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_state = new PParameter("state", "com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")), PParameterDirection.INOUT);
-
- private final PParameter parameter_parentState = new PParameter("parentState", "com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_state, parameter_parentState);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.parentState";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("state","parentState");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_state = body.getOrCreateVariableByName("state");
- PVariable var_parentState = body.getOrCreateVariableByName("parentState");
- PVariable var_subregion = body.getOrCreateVariableByName("subregion");
- new TypeConstraint(body, Tuples.flatTupleOf(var_state), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_parentState), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_state, parameter_state),
- new ExportedParameter(body, var_parentState, parameter_parentState)
- ));
- // State.region(parentState, subregion)
- new TypeConstraint(body, Tuples.flatTupleOf(var_parentState), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_parentState, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State", "region")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Region")));
- new Equality(body, var__virtual_0_, var_subregion);
- // Region.subvertex(subregion, state)
- new TypeConstraint(body, Tuples.flatTupleOf(var_subregion), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Region")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_subregion, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Region", "subvertex")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Vertex")));
- new Equality(body, var__virtual_1_, var_state);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Requirements.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Requirements.java
deleted file mode 100644
index 4825446..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Requirements.java
+++ /dev/null
@@ -1,564 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Querying all instances of an EClass that have a short "reference chain".
- *
- * pattern requirements(class : Class) {
- * Class.appliedStereotypeInstance.classifier.name(class, "Requirement");
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class Requirements extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.requirements pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class fClass;
-
- private static List parameterNames = makeImmutableList("class");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- this.fClass = pClass;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "class": return this.fClass;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fClass;
- default: return null;
- }
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getValueOfClass() {
- return this.fClass;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("class".equals(parameterName) ) {
- this.fClass = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- return false;
- }
-
- public void setClass(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass = pClass;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.requirements";
- }
-
- @Override
- public List parameterNames() {
- return Requirements.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass};
- }
-
- @Override
- public Requirements.Match toImmutable() {
- return isMutable() ? newMatch(fClass) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof Requirements.Match)) {
- Requirements.Match other = (Requirements.Match) obj;
- return Objects.equals(fClass, other.fClass);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public Requirements specification() {
- return Requirements.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static Requirements.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static Requirements.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Mutable(pClass);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static Requirements.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Immutable(pClass);
- }
-
- private static final class Mutable extends Requirements.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends Requirements.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- super(pClass);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.requirements pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Querying all instances of an EClass that have a short "reference chain".
- *
- * pattern requirements(class : Class) {
- * Class.appliedStereotypeInstance.classifier.name(class, "Requirement");
- * }
- *
- *
- * @see Match
- * @see Requirements
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static Requirements.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static Requirements.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_CLASS = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Requirements.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllMatches(new Object[]{pClass});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawGetOneArbitraryMatch(new Object[]{pClass});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawHasMatch(new Object[]{pClass});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawCountMatches(new Object[]{pClass});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Consumer super Requirements.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pClass the fixed value of pattern parameter class, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public Requirements.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return Requirements.Match.newMatch(pClass);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfclass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_CLASS, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfclass() {
- return rawStreamAllValuesOfclass(emptyArray());
- }
-
- @Override
- protected Requirements.Match tupleToMatch(final Tuple t) {
- try {
- return Requirements.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_CLASS));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected Requirements.Match arrayToMatch(final Object[] match) {
- try {
- return Requirements.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected Requirements.Match arrayToMatchMutable(final Object[] match) {
- try {
- return Requirements.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return Requirements.instance();
- }
- }
-
- private Requirements() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static Requirements instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected Requirements.Matcher instantiate(final ViatraQueryEngine engine) {
- return Requirements.Matcher.on(engine);
- }
-
- @Override
- public Requirements.Matcher instantiate() {
- return Requirements.Matcher.create();
- }
-
- @Override
- public Requirements.Match newEmptyMatch() {
- return Requirements.Match.newEmptyMatch();
- }
-
- @Override
- public Requirements.Match newMatch(final Object... parameters) {
- return Requirements.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link Requirements} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link Requirements#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final Requirements INSTANCE = new Requirements();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final Requirements.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_class = new PParameter("class", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.requirements";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_class = body.getOrCreateVariableByName("class");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class)
- ));
- // Class.appliedStereotypeInstance.classifier.name(class, "Requirement")
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new ConstantValue(body, var__virtual_0_, "Requirement");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Element", "appliedStereotypeInstance")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "InstanceSpecification")));
- PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "InstanceSpecification", "classifier")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement", "name")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "String")));
- new Equality(body, var__virtual_3_, var__virtual_0_);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/StateWithMostSubstates.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/StateWithMostSubstates.java
deleted file mode 100644
index 311fa78..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/StateWithMostSubstates.java
+++ /dev/null
@@ -1,566 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.NumberOfTransitiveSubstates;
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.aggregators.max;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Reusing a transitive closure and count aggregator pattern with the max aggregator.
- *
- * pattern stateWithMostSubstates(state : State) {
- * // the number of substates of this state
- * find numberOfTransitiveSubstates(state, count);
- * // is the maximum from all states
- * count == max find numberOfTransitiveSubstates(_, #substateCount);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class StateWithMostSubstates extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.stateWithMostSubstates pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private State fState;
-
- private static List parameterNames = makeImmutableList("state");
-
- private Match(final State pState) {
- this.fState = pState;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "state": return this.fState;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fState;
- default: return null;
- }
- }
-
- public State getState() {
- return this.fState;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("state".equals(parameterName) ) {
- this.fState = (State) newValue;
- return true;
- }
- return false;
- }
-
- public void setState(final State pState) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fState = pState;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.stateWithMostSubstates";
- }
-
- @Override
- public List parameterNames() {
- return StateWithMostSubstates.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fState};
- }
-
- @Override
- public StateWithMostSubstates.Match toImmutable() {
- return isMutable() ? newMatch(fState) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"state\"=" + prettyPrintValue(fState));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fState);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof StateWithMostSubstates.Match)) {
- StateWithMostSubstates.Match other = (StateWithMostSubstates.Match) obj;
- return Objects.equals(fState, other.fState);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public StateWithMostSubstates specification() {
- return StateWithMostSubstates.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static StateWithMostSubstates.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static StateWithMostSubstates.Match newMutableMatch(final State pState) {
- return new Mutable(pState);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static StateWithMostSubstates.Match newMatch(final State pState) {
- return new Immutable(pState);
- }
-
- private static final class Mutable extends StateWithMostSubstates.Match {
- Mutable(final State pState) {
- super(pState);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends StateWithMostSubstates.Match {
- Immutable(final State pState) {
- super(pState);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.stateWithMostSubstates pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Reusing a transitive closure and count aggregator pattern with the max aggregator.
- *
- * pattern stateWithMostSubstates(state : State) {
- * // the number of substates of this state
- * find numberOfTransitiveSubstates(state, count);
- * // is the maximum from all states
- * count == max find numberOfTransitiveSubstates(_, #substateCount);
- * }
- *
- *
- * @see Match
- * @see StateWithMostSubstates
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static StateWithMostSubstates.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static StateWithMostSubstates.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_STATE = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(StateWithMostSubstates.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final State pState) {
- return rawStreamAllMatches(new Object[]{pState}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final State pState) {
- return rawStreamAllMatches(new Object[]{pState});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final State pState) {
- return rawGetOneArbitraryMatch(new Object[]{pState});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final State pState) {
- return rawHasMatch(new Object[]{pState});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final State pState) {
- return rawCountMatches(new Object[]{pState});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final State pState, final Consumer super StateWithMostSubstates.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pState}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public StateWithMostSubstates.Match newMatch(final State pState) {
- return StateWithMostSubstates.Match.newMatch(pState);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfstate(final Object[] parameters) {
- return rawStreamAllValues(POSITION_STATE, parameters).map(State.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray());
- }
-
- @Override
- protected StateWithMostSubstates.Match tupleToMatch(final Tuple t) {
- try {
- return StateWithMostSubstates.Match.newMatch((State) t.get(POSITION_STATE));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected StateWithMostSubstates.Match arrayToMatch(final Object[] match) {
- try {
- return StateWithMostSubstates.Match.newMatch((State) match[POSITION_STATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected StateWithMostSubstates.Match arrayToMatchMutable(final Object[] match) {
- try {
- return StateWithMostSubstates.Match.newMutableMatch((State) match[POSITION_STATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return StateWithMostSubstates.instance();
- }
- }
-
- private StateWithMostSubstates() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static StateWithMostSubstates instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected StateWithMostSubstates.Matcher instantiate(final ViatraQueryEngine engine) {
- return StateWithMostSubstates.Matcher.on(engine);
- }
-
- @Override
- public StateWithMostSubstates.Matcher instantiate() {
- return StateWithMostSubstates.Matcher.create();
- }
-
- @Override
- public StateWithMostSubstates.Match newEmptyMatch() {
- return StateWithMostSubstates.Match.newEmptyMatch();
- }
-
- @Override
- public StateWithMostSubstates.Match newMatch(final Object... parameters) {
- return StateWithMostSubstates.Match.newMatch((com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link StateWithMostSubstates} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link StateWithMostSubstates#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final StateWithMostSubstates INSTANCE = new StateWithMostSubstates();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final StateWithMostSubstates.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_state = new PParameter("state", "com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_state);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.stateWithMostSubstates";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("state");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_state = body.getOrCreateVariableByName("state");
- PVariable var_count = body.getOrCreateVariableByName("count");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- PVariable var__substateCount = body.getOrCreateVariableByName("#substateCount");
- new TypeConstraint(body, Tuples.flatTupleOf(var_state), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_state, parameter_state)
- ));
- // // the number of substates of this state find numberOfTransitiveSubstates(state, count)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_state, var_count), NumberOfTransitiveSubstates.instance().getInternalQueryRepresentation());
- // // is the maximum from all states count == max find numberOfTransitiveSubstates(_, #substateCount)
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new AggregatorConstraint(new max().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var___0_, var__substateCount), NumberOfTransitiveSubstates.instance().getInternalQueryRepresentation(), var__virtual_0_, 1);
- new Equality(body, var_count, var__virtual_0_);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/StatesWithMoreIncomingTransitions.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/StatesWithMoreIncomingTransitions.java
deleted file mode 100644
index b0e9cef..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/StatesWithMoreIncomingTransitions.java
+++ /dev/null
@@ -1,582 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.incquerylabs.magicdraw.benchmark.queries.IncomingTransitions;
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
-import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.PatternMatchCounter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Reusing a simple pattern with a check expression. Made for reuse.
- *
- * pattern statesWithMoreIncomingTransitions(state : State) {
- * transitionCount == count find incomingTransitions(_, state);
- * check (transitionCount {@literal >} 1);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class StatesWithMoreIncomingTransitions extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.statesWithMoreIncomingTransitions pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private State fState;
-
- private static List parameterNames = makeImmutableList("state");
-
- private Match(final State pState) {
- this.fState = pState;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "state": return this.fState;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fState;
- default: return null;
- }
- }
-
- public State getState() {
- return this.fState;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("state".equals(parameterName) ) {
- this.fState = (State) newValue;
- return true;
- }
- return false;
- }
-
- public void setState(final State pState) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fState = pState;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.statesWithMoreIncomingTransitions";
- }
-
- @Override
- public List parameterNames() {
- return StatesWithMoreIncomingTransitions.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fState};
- }
-
- @Override
- public StatesWithMoreIncomingTransitions.Match toImmutable() {
- return isMutable() ? newMatch(fState) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"state\"=" + prettyPrintValue(fState));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fState);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof StatesWithMoreIncomingTransitions.Match)) {
- StatesWithMoreIncomingTransitions.Match other = (StatesWithMoreIncomingTransitions.Match) obj;
- return Objects.equals(fState, other.fState);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public StatesWithMoreIncomingTransitions specification() {
- return StatesWithMoreIncomingTransitions.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static StatesWithMoreIncomingTransitions.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static StatesWithMoreIncomingTransitions.Match newMutableMatch(final State pState) {
- return new Mutable(pState);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static StatesWithMoreIncomingTransitions.Match newMatch(final State pState) {
- return new Immutable(pState);
- }
-
- private static final class Mutable extends StatesWithMoreIncomingTransitions.Match {
- Mutable(final State pState) {
- super(pState);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends StatesWithMoreIncomingTransitions.Match {
- Immutable(final State pState) {
- super(pState);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.statesWithMoreIncomingTransitions pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Reusing a simple pattern with a check expression. Made for reuse.
- *
- * pattern statesWithMoreIncomingTransitions(state : State) {
- * transitionCount == count find incomingTransitions(_, state);
- * check (transitionCount {@literal >} 1);
- * }
- *
- *
- * @see Match
- * @see StatesWithMoreIncomingTransitions
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static StatesWithMoreIncomingTransitions.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static StatesWithMoreIncomingTransitions.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_STATE = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(StatesWithMoreIncomingTransitions.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final State pState) {
- return rawStreamAllMatches(new Object[]{pState}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final State pState) {
- return rawStreamAllMatches(new Object[]{pState});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final State pState) {
- return rawGetOneArbitraryMatch(new Object[]{pState});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final State pState) {
- return rawHasMatch(new Object[]{pState});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final State pState) {
- return rawCountMatches(new Object[]{pState});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final State pState, final Consumer super StatesWithMoreIncomingTransitions.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pState}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public StatesWithMoreIncomingTransitions.Match newMatch(final State pState) {
- return StatesWithMoreIncomingTransitions.Match.newMatch(pState);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfstate(final Object[] parameters) {
- return rawStreamAllValues(POSITION_STATE, parameters).map(State.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray());
- }
-
- @Override
- protected StatesWithMoreIncomingTransitions.Match tupleToMatch(final Tuple t) {
- try {
- return StatesWithMoreIncomingTransitions.Match.newMatch((State) t.get(POSITION_STATE));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected StatesWithMoreIncomingTransitions.Match arrayToMatch(final Object[] match) {
- try {
- return StatesWithMoreIncomingTransitions.Match.newMatch((State) match[POSITION_STATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected StatesWithMoreIncomingTransitions.Match arrayToMatchMutable(final Object[] match) {
- try {
- return StatesWithMoreIncomingTransitions.Match.newMutableMatch((State) match[POSITION_STATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return StatesWithMoreIncomingTransitions.instance();
- }
- }
-
- private StatesWithMoreIncomingTransitions() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static StatesWithMoreIncomingTransitions instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected StatesWithMoreIncomingTransitions.Matcher instantiate(final ViatraQueryEngine engine) {
- return StatesWithMoreIncomingTransitions.Matcher.on(engine);
- }
-
- @Override
- public StatesWithMoreIncomingTransitions.Matcher instantiate() {
- return StatesWithMoreIncomingTransitions.Matcher.create();
- }
-
- @Override
- public StatesWithMoreIncomingTransitions.Match newEmptyMatch() {
- return StatesWithMoreIncomingTransitions.Match.newEmptyMatch();
- }
-
- @Override
- public StatesWithMoreIncomingTransitions.Match newMatch(final Object... parameters) {
- return StatesWithMoreIncomingTransitions.Match.newMatch((com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link StatesWithMoreIncomingTransitions} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link StatesWithMoreIncomingTransitions#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final StatesWithMoreIncomingTransitions INSTANCE = new StatesWithMoreIncomingTransitions();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final StatesWithMoreIncomingTransitions.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_state = new PParameter("state", "com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_state);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.statesWithMoreIncomingTransitions";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("state");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_state = body.getOrCreateVariableByName("state");
- PVariable var_transitionCount = body.getOrCreateVariableByName("transitionCount");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- new TypeConstraint(body, Tuples.flatTupleOf(var_state), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_state, parameter_state)
- ));
- // transitionCount == count find incomingTransitions(_, state)
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new PatternMatchCounter(body, Tuples.flatTupleOf(var___0_, var_state), IncomingTransitions.instance().getInternalQueryRepresentation(), var__virtual_0_);
- new Equality(body, var_transitionCount, var__virtual_0_);
- // check (transitionCount > 1)
- new ExpressionEvaluation(body, new IExpressionEvaluator() {
-
- @Override
- public String getShortDescription() {
- return "Expression evaluation from pattern statesWithMoreIncomingTransitions";
- }
-
- @Override
- public Iterable getInputParameterNames() {
- return Arrays.asList("transitionCount");}
-
- @Override
- public Object evaluateExpression(IValueProvider provider) throws Exception {
- Integer transitionCount = (Integer) provider.getValue("transitionCount");
- return evaluateExpression_1_1(transitionCount);
- }
- }, null);
- bodies.add(body);
- }
- return bodies;
- }
- }
-
- private static boolean evaluateExpression_1_1(final Integer transitionCount) {
- return ((transitionCount).intValue() > 1);
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/StatesWithShortNames.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/StatesWithShortNames.java
deleted file mode 100644
index c9c9ba8..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/StatesWithShortNames.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
-import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *
- * Reusing a simple pattern with transitive closure.
- *
- * //pattern transitiveSubstates(state : State, transitiveSubstate : State) {
- * // find parentState+(transitiveSubstate, state);
- * //}
- *
- *
- * Returns states with short names.
- *
- * pattern statesWithShortNames(state : State) {
- * State.name(state, name);
- * check(name.length {@literal <} 6);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class StatesWithShortNames extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.magicdraw.benchmark.queries.statesWithShortNames pattern,
- * to be used in conjunction with {@link Matcher}.
- *
- * Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
- * Each instance is a (possibly partial) substitution of pattern parameters,
- * usable to represent a match of the pattern in the result of a query,
- * or to specify the bound (fixed) input parameters when issuing a query.
- *
- * @see Matcher
- *
- */
- public static abstract class Match extends BasePatternMatch {
- private State fState;
-
- private static List parameterNames = makeImmutableList("state");
-
- private Match(final State pState) {
- this.fState = pState;
- }
-
- @Override
- public Object get(final String parameterName) {
- switch(parameterName) {
- case "state": return this.fState;
- default: return null;
- }
- }
-
- @Override
- public Object get(final int index) {
- switch(index) {
- case 0: return this.fState;
- default: return null;
- }
- }
-
- public State getState() {
- return this.fState;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("state".equals(parameterName) ) {
- this.fState = (State) newValue;
- return true;
- }
- return false;
- }
-
- public void setState(final State pState) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fState = pState;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.statesWithShortNames";
- }
-
- @Override
- public List parameterNames() {
- return StatesWithShortNames.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fState};
- }
-
- @Override
- public StatesWithShortNames.Match toImmutable() {
- return isMutable() ? newMatch(fState) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"state\"=" + prettyPrintValue(fState));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fState);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof StatesWithShortNames.Match)) {
- StatesWithShortNames.Match other = (StatesWithShortNames.Match) obj;
- return Objects.equals(fState, other.fState);
- } else {
- // this should be infrequent
- if (!(obj instanceof IPatternMatch)) {
- return false;
- }
- IPatternMatch otherSig = (IPatternMatch) obj;
- return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
- }
- }
-
- @Override
- public StatesWithShortNames specification() {
- return StatesWithShortNames.instance();
- }
-
- /**
- * Returns an empty, mutable match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @return the empty match.
- *
- */
- public static StatesWithShortNames.Match newEmptyMatch() {
- return new Mutable(null);
- }
-
- /**
- * Returns a mutable (partial) match.
- * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
- *
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static StatesWithShortNames.Match newMutableMatch(final State pState) {
- return new Mutable(pState);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static StatesWithShortNames.Match newMatch(final State pState) {
- return new Immutable(pState);
- }
-
- private static final class Mutable extends StatesWithShortNames.Match {
- Mutable(final State pState) {
- super(pState);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends StatesWithShortNames.Match {
- Immutable(final State pState) {
- super(pState);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.magicdraw.benchmark.queries.statesWithShortNames pattern,
- * providing pattern-specific query methods.
- *
- *
Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
- * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
- *
- *
Matches of the pattern will be represented as {@link Match}.
- *
- *
Original source:
- *
- * Reusing a simple pattern with transitive closure.
- *
- * //pattern transitiveSubstates(state : State, transitiveSubstate : State) {
- * // find parentState+(transitiveSubstate, state);
- * //}
- *
- *
- * Returns states with short names.
- *
- * pattern statesWithShortNames(state : State) {
- * State.name(state, name);
- * check(name.length {@literal <} 6);
- * }
- *
- *
- * @see Match
- * @see StatesWithShortNames
- *
- */
- public static class Matcher extends BaseMatcher {
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- public static StatesWithShortNames.Matcher on(final ViatraQueryEngine engine) {
- // check if matcher already exists
- Matcher matcher = engine.getExistingMatcher(querySpecification());
- if (matcher == null) {
- matcher = (Matcher)engine.getMatcher(querySpecification());
- }
- return matcher;
- }
-
- /**
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- * @return an initialized matcher
- * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
- *
- */
- public static StatesWithShortNames.Matcher create() {
- return new Matcher();
- }
-
- private static final int POSITION_STATE = 0;
-
- private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(StatesWithShortNames.Matcher.class);
-
- /**
- * Initializes the pattern matcher within an existing VIATRA Query engine.
- * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
- *
- * @param engine the existing VIATRA Query engine in which this matcher will be created.
- * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
- *
- */
- private Matcher() {
- super(querySpecification());
- }
-
- /**
- * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final State pState) {
- return rawStreamAllMatches(new Object[]{pState}).collect(Collectors.toSet());
- }
-
- /**
- * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
- *
- * NOTE: It is important not to modify the source model while the stream is being processed.
- * If the match set of the pattern changes during processing, the contents of the stream is undefined.
- * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final State pState) {
- return rawStreamAllMatches(new Object[]{pState});
- }
-
- /**
- * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final State pState) {
- return rawGetOneArbitraryMatch(new Object[]{pState});
- }
-
- /**
- * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
- * under any possible substitution of the unspecified parameters (if any).
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final State pState) {
- return rawHasMatch(new Object[]{pState});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final State pState) {
- return rawCountMatches(new Object[]{pState});
- }
-
- /**
- * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
- * Neither determinism nor randomness of selection is guaranteed.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @param processor the action that will process the selected match.
- * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
- *
- */
- public boolean forOneArbitraryMatch(final State pState, final Consumer super StatesWithShortNames.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pState}, processor);
- }
-
- /**
- * Returns a new (partial) match.
- * This can be used e.g. to call the matcher with a partial match.
- * The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
- * @param pState the fixed value of pattern parameter state, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public StatesWithShortNames.Match newMatch(final State pState) {
- return StatesWithShortNames.Match.newMatch(pState);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfstate(final Object[] parameters) {
- return rawStreamAllValues(POSITION_STATE, parameters).map(State.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for state.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfstate() {
- return rawStreamAllValuesOfstate(emptyArray());
- }
-
- @Override
- protected StatesWithShortNames.Match tupleToMatch(final Tuple t) {
- try {
- return StatesWithShortNames.Match.newMatch((State) t.get(POSITION_STATE));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected StatesWithShortNames.Match arrayToMatch(final Object[] match) {
- try {
- return StatesWithShortNames.Match.newMatch((State) match[POSITION_STATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected StatesWithShortNames.Match arrayToMatchMutable(final Object[] match) {
- try {
- return StatesWithShortNames.Match.newMutableMatch((State) match[POSITION_STATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- /**
- * @return the singleton instance of the query specification of this pattern
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IQuerySpecification querySpecification() {
- return StatesWithShortNames.instance();
- }
- }
-
- private StatesWithShortNames() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static StatesWithShortNames instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected StatesWithShortNames.Matcher instantiate(final ViatraQueryEngine engine) {
- return StatesWithShortNames.Matcher.on(engine);
- }
-
- @Override
- public StatesWithShortNames.Matcher instantiate() {
- return StatesWithShortNames.Matcher.create();
- }
-
- @Override
- public StatesWithShortNames.Match newEmptyMatch() {
- return StatesWithShortNames.Match.newEmptyMatch();
- }
-
- @Override
- public StatesWithShortNames.Match newMatch(final Object... parameters) {
- return StatesWithShortNames.Match.newMatch((com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link StatesWithShortNames} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link StatesWithShortNames#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private static final StatesWithShortNames INSTANCE = new StatesWithShortNames();
-
- /**
- * Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
- * This initialization order is required to support indirect recursion.
- *
- *
The static initializer is defined using a helper field to work around limitations of the code generator.
- *
- */
- private static final Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private static final StatesWithShortNames.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_state = new PParameter("state", "com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_state);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.magicdraw.benchmark.queries.statesWithShortNames";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("state");
- }
-
- @Override
- public List getParameters() {
- return parameters;
- }
-
- @Override
- public Set doGetContainedBodies() {
- setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
- Set bodies = new LinkedHashSet<>();
- {
- PBody body = new PBody(this);
- PVariable var_state = body.getOrCreateVariableByName("state");
- PVariable var_name = body.getOrCreateVariableByName("name");
- new TypeConstraint(body, Tuples.flatTupleOf(var_state), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_state, parameter_state)
- ));
- // State.name(state, name)
- new TypeConstraint(body, Tuples.flatTupleOf(var_state), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "State")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_state, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement", "name")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "String")));
- new Equality(body, var__virtual_0_, var_name);
- // check(name.length < 6)
- new ExpressionEvaluation(body, new IExpressionEvaluator() {
-
- @Override
- public String getShortDescription() {
- return "Expression evaluation from pattern statesWithShortNames";
- }
-
- @Override
- public Iterable getInputParameterNames() {
- return Arrays.asList("name");}
-
- @Override
- public Object evaluateExpression(IValueProvider provider) throws Exception {
- String name = (String) provider.getValue("name");
- return evaluateExpression_1_1(name);
- }
- }, null);
- bodies.add(body);
- }
- return bodies;
- }
- }
-
- private static boolean evaluateExpression_1_1(final String name) {
- int _length = name.length();
- boolean _lessThan = (_length < 6);
- return _lessThan;
- }
-}
diff --git a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Subregions.java b/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Subregions.java
deleted file mode 100644
index 1f2f65c..0000000
--- a/com.incquerylabs.magicdraw.benchmark/src/generated/vql/com/incquerylabs/magicdraw/benchmark/queries/Subregions.java
+++ /dev/null
@@ -1,737 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.magicdraw.benchmark/src/main/java/com/incquerylabs/magicdraw/benchmark/queries/APerformanceQueries.vql
- */
-package com.incquerylabs.magicdraw.benchmark.queries;
-
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.Region;
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.function.Consumer;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-import org.apache.log4j.Logger;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.IPatternMatch;
-import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
-import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
-import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
-import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
-import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
-import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
-import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
-import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
-import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
-import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
-
-/**
- * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
- *
- * Original source:
- *