) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.snapshotmaker.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static DeduciblePortType INSTANCE = new DeduciblePortType();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static DeduciblePortType.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_port = new PParameter("port", "com.nomagic.uml2.ext.magicdraw.compositestructures.mdports.Port", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5", "Port")), PParameterDirection.INOUT);
-
- private final PParameter parameter_type = new PParameter("type", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Type", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5", "Type")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_port, parameter_type);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.snapshotmaker.queries.DeduciblePortType";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("port","type");
- }
-
- @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_port = body.getOrCreateVariableByName("port");
- PVariable var_type = body.getOrCreateVariableByName("type");
- PVariable var_other = body.getOrCreateVariableByName("other");
- new TypeConstraint(body, Tuples.flatTupleOf(var_port), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Port")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_type), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Type")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_port, parameter_port),
- new ExportedParameter(body, var_type, parameter_type)
- ));
- // neg find PortWithSpecifiedType(port)
- new NegativePatternCall(body, Tuples.flatTupleOf(var_port), PortWithSpecifiedType.instance().getInternalQueryRepresentation());
- // find ConnectedPort(port, other)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_port, var_other), ConnectedPort.instance().getInternalQueryRepresentation());
- // Port.type(other, type)
- new TypeConstraint(body, Tuples.flatTupleOf(var_other), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Port")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_other, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "TypedElement", "type")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Type")));
- new Equality(body, var__virtual_0_, var_type);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/SearchQueries.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/SearchQueries.java
deleted file mode 100644
index ac82151..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/SearchQueries.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/snapshotmaker/queries/SearchQueries.vql
- */
-package com.incquerylabs.v4md.snapshotmaker.queries;
-
-import com.incquerylabs.v4md.snapshotmaker.queries.DeduciblePortType;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
-
-/**
- * A pattern group formed of all public patterns defined in SearchQueries.vql.
- *
- * Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare
- * a VIATRA Query engine for matching all patterns originally defined in file SearchQueries.vql,
- * in order to achieve better performance than one-by-one on-demand matcher initialization.
- *
- *
From package com.incquerylabs.v4md.snapshotmaker.queries, the group contains the definition of the following patterns:
- * - DeduciblePortType
- *
- *
- * @see IQueryGroup
- *
- */
-@SuppressWarnings("all")
-public final class SearchQueries extends BaseGeneratedPatternGroup {
- /**
- * Access the pattern group.
- *
- * @return the singleton instance of the group
- * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
- *
- */
- public static SearchQueries instance() {
- if (INSTANCE == null) {
- INSTANCE = new SearchQueries();
- }
- return INSTANCE;
- }
-
- private static SearchQueries INSTANCE;
-
- private SearchQueries() {
- querySpecifications.add(DeduciblePortType.instance());
- }
-
- public DeduciblePortType getDeduciblePortType() {
- return DeduciblePortType.instance();
- }
-
- public DeduciblePortType.Matcher getDeduciblePortType(final ViatraQueryEngine engine) {
- return DeduciblePortType.Matcher.on(engine);
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/UMLTestQueries.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/UMLTestQueries.java
deleted file mode 100644
index 6c21145..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/UMLTestQueries.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/snapshotmaker/queries/UMLTestQueries.vql
- */
-package com.incquerylabs.v4md.snapshotmaker.queries;
-
-import com.incquerylabs.v4md.snapshotmaker.queries.CompnoentsWithName;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
-
-/**
- * A pattern group formed of all public patterns defined in UMLTestQueries.vql.
- *
- * Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare
- * a VIATRA Query engine for matching all patterns originally defined in file UMLTestQueries.vql,
- * in order to achieve better performance than one-by-one on-demand matcher initialization.
- *
- *
From package com.incquerylabs.v4md.snapshotmaker.queries, the group contains the definition of the following patterns:
- * - CompnoentsWithName
- *
- *
- * @see IQueryGroup
- *
- */
-@SuppressWarnings("all")
-public final class UMLTestQueries extends BaseGeneratedPatternGroup {
- /**
- * Access the pattern group.
- *
- * @return the singleton instance of the group
- * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
- *
- */
- public static UMLTestQueries instance() {
- if (INSTANCE == null) {
- INSTANCE = new UMLTestQueries();
- }
- return INSTANCE;
- }
-
- private static UMLTestQueries INSTANCE;
-
- private UMLTestQueries() {
- querySpecifications.add(CompnoentsWithName.instance());
- }
-
- public CompnoentsWithName getCompnoentsWithName() {
- return CompnoentsWithName.instance();
- }
-
- public CompnoentsWithName.Matcher getCompnoentsWithName(final ViatraQueryEngine engine) {
- return CompnoentsWithName.Matcher.on(engine);
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/internal/ConnectedPort.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/internal/ConnectedPort.java
deleted file mode 100644
index 7db73b1..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/internal/ConnectedPort.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/snapshotmaker/queries/SearchQueries.vql
- */
-package com.incquerylabs.v4md.snapshotmaker.queries.internal;
-
-import java.util.Arrays;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
-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.basicdeferred.Inequality;
-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.Tuples;
-
-/**
- * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way.
- *
- * Original source:
- *
- * private pattern ConnectedPort(one : Port, other : Port) {
- * Port.end(one, oneEnd);
- * ConnectorEnd._connectorOfEnd(oneEnd, conn);
- * Connector.end(conn, otherEnd);
- * oneEnd != otherEnd;
- * Port.end(other, otherEnd);
- * }
- *
- *
- * @see GenericPatternMatcher
- * @see GenericPatternMatch
- *
- */
-@SuppressWarnings("all")
-public final class ConnectedPort extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher {
- private ConnectedPort() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ConnectedPort instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.snapshotmaker.queries.internal.ConnectedPort (visibility: PUBLIC, simpleName: ConnectedPort, identifier: com.incquerylabs.v4md.snapshotmaker.queries.internal.ConnectedPort, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.snapshotmaker.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.snapshotmaker.queries.internal.ConnectedPort (visibility: PUBLIC, simpleName: ConnectedPort, identifier: com.incquerylabs.v4md.snapshotmaker.queries.internal.ConnectedPort, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.snapshotmaker.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static ConnectedPort INSTANCE = new ConnectedPort();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static ConnectedPort.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_one = new PParameter("one", "com.nomagic.uml2.ext.magicdraw.compositestructures.mdports.Port", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5", "Port")), PParameterDirection.INOUT);
-
- private final PParameter parameter_other = new PParameter("other", "com.nomagic.uml2.ext.magicdraw.compositestructures.mdports.Port", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5", "Port")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_one, parameter_other);
-
- private GeneratedPQuery() {
- super(PVisibility.PRIVATE);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.snapshotmaker.queries.ConnectedPort";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("one","other");
- }
-
- @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_one = body.getOrCreateVariableByName("one");
- PVariable var_other = body.getOrCreateVariableByName("other");
- PVariable var_oneEnd = body.getOrCreateVariableByName("oneEnd");
- PVariable var_conn = body.getOrCreateVariableByName("conn");
- PVariable var_otherEnd = body.getOrCreateVariableByName("otherEnd");
- new TypeConstraint(body, Tuples.flatTupleOf(var_one), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Port")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_other), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Port")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_one, parameter_one),
- new ExportedParameter(body, var_other, parameter_other)
- ));
- // Port.end(one, oneEnd)
- new TypeConstraint(body, Tuples.flatTupleOf(var_one), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Port")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_one, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "ConnectableElement", "end")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "ConnectorEnd")));
- new Equality(body, var__virtual_0_, var_oneEnd);
- // ConnectorEnd._connectorOfEnd(oneEnd, conn)
- new TypeConstraint(body, Tuples.flatTupleOf(var_oneEnd), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "ConnectorEnd")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_oneEnd, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "ConnectorEnd", "_connectorOfEnd")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Connector")));
- new Equality(body, var__virtual_1_, var_conn);
- // Connector.end(conn, otherEnd)
- new TypeConstraint(body, Tuples.flatTupleOf(var_conn), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Connector")));
- PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_conn, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Connector", "end")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "ConnectorEnd")));
- new Equality(body, var__virtual_2_, var_otherEnd);
- // oneEnd != otherEnd
- new Inequality(body, var_oneEnd, var_otherEnd);
- // Port.end(other, otherEnd)
- new TypeConstraint(body, Tuples.flatTupleOf(var_other), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Port")));
- PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_other, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "ConnectableElement", "end")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "ConnectorEnd")));
- new Equality(body, var__virtual_3_, var_otherEnd);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/internal/PortWithSpecifiedType.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/internal/PortWithSpecifiedType.java
deleted file mode 100644
index a6f8926..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/internal/PortWithSpecifiedType.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/snapshotmaker/queries/SearchQueries.vql
- */
-package com.incquerylabs.v4md.snapshotmaker.queries.internal;
-
-import java.util.Arrays;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecificationWithGenericMatcher;
-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.Tuples;
-
-/**
- * A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way.
- *
- * Original source:
- *
- * private pattern PortWithSpecifiedType(port : Port) {
- * Port.type(port, _);
- * }
- *
- *
- * @see GenericPatternMatcher
- * @see GenericPatternMatch
- *
- */
-@SuppressWarnings("all")
-public final class PortWithSpecifiedType extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher {
- private PortWithSpecifiedType() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static PortWithSpecifiedType instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.snapshotmaker.queries.internal.PortWithSpecifiedType (visibility: PUBLIC, simpleName: PortWithSpecifiedType, identifier: com.incquerylabs.v4md.snapshotmaker.queries.internal.PortWithSpecifiedType, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.snapshotmaker.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.snapshotmaker.queries.internal.PortWithSpecifiedType (visibility: PUBLIC, simpleName: PortWithSpecifiedType, identifier: com.incquerylabs.v4md.snapshotmaker.queries.internal.PortWithSpecifiedType, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.snapshotmaker.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static PortWithSpecifiedType INSTANCE = new PortWithSpecifiedType();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static PortWithSpecifiedType.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_port = new PParameter("port", "com.nomagic.uml2.ext.magicdraw.compositestructures.mdports.Port", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5", "Port")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_port);
-
- private GeneratedPQuery() {
- super(PVisibility.PRIVATE);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.snapshotmaker.queries.PortWithSpecifiedType";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("port");
- }
-
- @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_port = body.getOrCreateVariableByName("port");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- new TypeConstraint(body, Tuples.flatTupleOf(var_port), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Port")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_port, parameter_port)
- ));
- // Port.type(port, _)
- new TypeConstraint(body, Tuples.flatTupleOf(var_port), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Port")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_port, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "TypedElement", "type")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5", "Type")));
- new Equality(body, var__virtual_0_, var___0_);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/internal/SearchQueriesAll.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/internal/SearchQueriesAll.java
deleted file mode 100644
index 551727d..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/snapshotmaker/queries/internal/SearchQueriesAll.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/snapshotmaker/queries/SearchQueries.vql
- */
-package com.incquerylabs.v4md.snapshotmaker.queries.internal;
-
-import com.incquerylabs.v4md.snapshotmaker.queries.DeduciblePortType;
-import com.incquerylabs.v4md.snapshotmaker.queries.internal.ConnectedPort;
-import com.incquerylabs.v4md.snapshotmaker.queries.internal.PortWithSpecifiedType;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
-
-/**
- * A pattern group formed of all patterns defined in SearchQueries.vql.
- *
- * A private group that includes private patterns as well. Only intended use case is for pattern testing.
- *
- *
From package com.incquerylabs.v4md.snapshotmaker.queries, the group contains the definition of the following patterns:
- * - DeduciblePortType
- * - PortWithSpecifiedType
- * - ConnectedPort
- *
- *
- * @see IQueryGroup
- *
- */
-@SuppressWarnings("all")
-public final class SearchQueriesAll extends BaseGeneratedPatternGroup {
- /**
- * Access the pattern group.
- *
- * @return the singleton instance of the group
- * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
- *
- */
- public static SearchQueriesAll instance() {
- if (INSTANCE == null) {
- INSTANCE = new SearchQueriesAll();
- }
- return INSTANCE;
- }
-
- private static SearchQueriesAll INSTANCE;
-
- private SearchQueriesAll() {
- querySpecifications.add(DeduciblePortType.instance());
- querySpecifications.add(PortWithSpecifiedType.instance());
- querySpecifications.add(ConnectedPort.instance());
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Aggregator_Functions.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Aggregator_Functions.java
deleted file mode 100644
index 04e5dd4..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Aggregator_Functions.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Aggregator_Functions.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.AverageNumberOfAttributes;
-import com.incquerylabs.v4md.test.queries.ClassAttributes;
-import com.incquerylabs.v4md.test.queries.ClassNumberOfAttributes;
-import com.incquerylabs.v4md.test.queries.ClassWithMaxNumberOfAttributes;
-import com.incquerylabs.v4md.test.queries.Classes;
-import com.incquerylabs.v4md.test.queries.SumOfClassAttributes;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
-
-/**
- * A pattern group formed of all public patterns defined in Aggregator_Functions.vql.
- *
- * Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare
- * a VIATRA Query engine for matching all patterns originally defined in file Aggregator_Functions.vql,
- * in order to achieve better performance than one-by-one on-demand matcher initialization.
- *
- *
From package com.incquerylabs.v4md.test.queries, the group contains the definition of the following patterns:
- * - classes
- * - classAttributes
- * - classNumberOfAttributes
- * - classWithMaxNumberOfAttributes
- * - sumOfClassAttributes
- * - averageNumberOfAttributes
- *
- *
- * @see IQueryGroup
- *
- */
-@SuppressWarnings("all")
-public final class Aggregator_Functions extends BaseGeneratedPatternGroup {
- /**
- * Access the pattern group.
- *
- * @return the singleton instance of the group
- * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
- *
- */
- public static Aggregator_Functions instance() {
- if (INSTANCE == null) {
- INSTANCE = new Aggregator_Functions();
- }
- return INSTANCE;
- }
-
- private static Aggregator_Functions INSTANCE;
-
- private Aggregator_Functions() {
- querySpecifications.add(Classes.instance());
- querySpecifications.add(ClassAttributes.instance());
- querySpecifications.add(ClassNumberOfAttributes.instance());
- querySpecifications.add(ClassWithMaxNumberOfAttributes.instance());
- querySpecifications.add(SumOfClassAttributes.instance());
- querySpecifications.add(AverageNumberOfAttributes.instance());
- }
-
- public Classes getClasses() {
- return Classes.instance();
- }
-
- public Classes.Matcher getClasses(final ViatraQueryEngine engine) {
- return Classes.Matcher.on(engine);
- }
-
- public ClassAttributes getClassAttributes() {
- return ClassAttributes.instance();
- }
-
- public ClassAttributes.Matcher getClassAttributes(final ViatraQueryEngine engine) {
- return ClassAttributes.Matcher.on(engine);
- }
-
- public ClassNumberOfAttributes getClassNumberOfAttributes() {
- return ClassNumberOfAttributes.instance();
- }
-
- public ClassNumberOfAttributes.Matcher getClassNumberOfAttributes(final ViatraQueryEngine engine) {
- return ClassNumberOfAttributes.Matcher.on(engine);
- }
-
- public ClassWithMaxNumberOfAttributes getClassWithMaxNumberOfAttributes() {
- return ClassWithMaxNumberOfAttributes.instance();
- }
-
- public ClassWithMaxNumberOfAttributes.Matcher getClassWithMaxNumberOfAttributes(final ViatraQueryEngine engine) {
- return ClassWithMaxNumberOfAttributes.Matcher.on(engine);
- }
-
- public SumOfClassAttributes getSumOfClassAttributes() {
- return SumOfClassAttributes.instance();
- }
-
- public SumOfClassAttributes.Matcher getSumOfClassAttributes(final ViatraQueryEngine engine) {
- return SumOfClassAttributes.Matcher.on(engine);
- }
-
- public AverageNumberOfAttributes getAverageNumberOfAttributes() {
- return AverageNumberOfAttributes.instance();
- }
-
- public AverageNumberOfAttributes.Matcher getAverageNumberOfAttributes(final ViatraQueryEngine engine) {
- return AverageNumberOfAttributes.Matcher.on(engine);
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/AverageNumberOfAttributes.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/AverageNumberOfAttributes.java
deleted file mode 100644
index 26ee8b7..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/AverageNumberOfAttributes.java
+++ /dev/null
@@ -1,854 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Aggregator_Functions.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.ClassNumberOfAttributes;
-import com.incquerylabs.v4md.test.queries.Classes;
-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.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.matchers.aggregators.sum;
-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.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.basicdeferred.ExpressionEvaluation;
-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.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:
- *
- * //Calculates average number of attributes per class in the model
- * pattern averageNumberOfAttributes(number : java Float, s : java Integer, c : java Integer) {
- * //calculates sum
- * s == sum find classNumberOfAttributes(_c, #tempNumber);
- * //determines the number of classes
- * c == count find classes(_c2);
- * //Calculates average in an eval() expression
- * //similar to check() in an eval expression standard Java code can be used
- * number == eval(s.floatValue/c.floatValue);
- *
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class AverageNumberOfAttributes extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.averageNumberOfAttributes 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 Float fNumber;
-
- private Integer fS;
-
- private Integer fC;
-
- private static List parameterNames = makeImmutableList("number", "s", "c");
-
- private Match(final Float pNumber, final Integer pS, final Integer pC) {
- this.fNumber = pNumber;
- this.fS = pS;
- this.fC = pC;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("number".equals(parameterName)) return this.fNumber;
- if ("s".equals(parameterName)) return this.fS;
- if ("c".equals(parameterName)) return this.fC;
- return null;
- }
-
- public Float getNumber() {
- return this.fNumber;
- }
-
- public Integer getS() {
- return this.fS;
- }
-
- public Integer getC() {
- return this.fC;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("number".equals(parameterName) ) {
- this.fNumber = (Float) newValue;
- return true;
- }
- if ("s".equals(parameterName) ) {
- this.fS = (Integer) newValue;
- return true;
- }
- if ("c".equals(parameterName) ) {
- this.fC = (Integer) newValue;
- return true;
- }
- return false;
- }
-
- public void setNumber(final Float pNumber) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fNumber = pNumber;
- }
-
- public void setS(final Integer pS) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fS = pS;
- }
-
- public void setC(final Integer pC) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fC = pC;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.averageNumberOfAttributes";
- }
-
- @Override
- public List parameterNames() {
- return AverageNumberOfAttributes.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fNumber, fS, fC};
- }
-
- @Override
- public AverageNumberOfAttributes.Match toImmutable() {
- return isMutable() ? newMatch(fNumber, fS, fC) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"number\"=" + prettyPrintValue(fNumber) + ", ");
- result.append("\"s\"=" + prettyPrintValue(fS) + ", ");
- result.append("\"c\"=" + prettyPrintValue(fC));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fNumber, fS, fC);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof AverageNumberOfAttributes.Match)) {
- AverageNumberOfAttributes.Match other = (AverageNumberOfAttributes.Match) obj;
- return Objects.equals(fNumber, other.fNumber) && Objects.equals(fS, other.fS) && Objects.equals(fC, other.fC);
- } 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 AverageNumberOfAttributes specification() {
- return AverageNumberOfAttributes.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 AverageNumberOfAttributes.Match newEmptyMatch() {
- return new Mutable(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 pNumber the fixed value of pattern parameter number, or null if not bound.
- * @param pS the fixed value of pattern parameter s, or null if not bound.
- * @param pC the fixed value of pattern parameter c, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static AverageNumberOfAttributes.Match newMutableMatch(final Float pNumber, final Integer pS, final Integer pC) {
- return new Mutable(pNumber, pS, pC);
- }
-
- /**
- * 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 pNumber the fixed value of pattern parameter number, or null if not bound.
- * @param pS the fixed value of pattern parameter s, or null if not bound.
- * @param pC the fixed value of pattern parameter c, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static AverageNumberOfAttributes.Match newMatch(final Float pNumber, final Integer pS, final Integer pC) {
- return new Immutable(pNumber, pS, pC);
- }
-
- private static final class Mutable extends AverageNumberOfAttributes.Match {
- Mutable(final Float pNumber, final Integer pS, final Integer pC) {
- super(pNumber, pS, pC);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends AverageNumberOfAttributes.Match {
- Immutable(final Float pNumber, final Integer pS, final Integer pC) {
- super(pNumber, pS, pC);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.averageNumberOfAttributes 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:
- *
- * //Calculates average number of attributes per class in the model
- * pattern averageNumberOfAttributes(number : java Float, s : java Integer, c : java Integer) {
- * //calculates sum
- * s == sum find classNumberOfAttributes(_c, #tempNumber);
- * //determines the number of classes
- * c == count find classes(_c2);
- * //Calculates average in an eval() expression
- * //similar to check() in an eval expression standard Java code can be used
- * number == eval(s.floatValue/c.floatValue);
- *
- * }
- *
- *
- * @see Match
- * @see AverageNumberOfAttributes
- *
- */
- 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 AverageNumberOfAttributes.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 AverageNumberOfAttributes.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_NUMBER = 0;
-
- private final static int POSITION_S = 1;
-
- private final static int POSITION_C = 2;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AverageNumberOfAttributes.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 pNumber the fixed value of pattern parameter number, or null if not bound.
- * @param pS the fixed value of pattern parameter s, or null if not bound.
- * @param pC the fixed value of pattern parameter c, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final Float pNumber, final Integer pS, final Integer pC) {
- return rawStreamAllMatches(new Object[]{pNumber, pS, pC}).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 pNumber the fixed value of pattern parameter number, or null if not bound.
- * @param pS the fixed value of pattern parameter s, or null if not bound.
- * @param pC the fixed value of pattern parameter c, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final Float pNumber, final Integer pS, final Integer pC) {
- return rawStreamAllMatches(new Object[]{pNumber, pS, pC});
- }
-
- /**
- * 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 pNumber the fixed value of pattern parameter number, or null if not bound.
- * @param pS the fixed value of pattern parameter s, or null if not bound.
- * @param pC the fixed value of pattern parameter c, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final Float pNumber, final Integer pS, final Integer pC) {
- return rawGetOneArbitraryMatch(new Object[]{pNumber, pS, pC});
- }
-
- /**
- * 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 pNumber the fixed value of pattern parameter number, or null if not bound.
- * @param pS the fixed value of pattern parameter s, or null if not bound.
- * @param pC the fixed value of pattern parameter c, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final Float pNumber, final Integer pS, final Integer pC) {
- return rawHasMatch(new Object[]{pNumber, pS, pC});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pNumber the fixed value of pattern parameter number, or null if not bound.
- * @param pS the fixed value of pattern parameter s, or null if not bound.
- * @param pC the fixed value of pattern parameter c, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final Float pNumber, final Integer pS, final Integer pC) {
- return rawCountMatches(new Object[]{pNumber, pS, pC});
- }
-
- /**
- * 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 pNumber the fixed value of pattern parameter number, or null if not bound.
- * @param pS the fixed value of pattern parameter s, or null if not bound.
- * @param pC the fixed value of pattern parameter c, 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 Float pNumber, final Integer pS, final Integer pC, final Consumer super AverageNumberOfAttributes.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pNumber, pS, pC}, 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 pNumber the fixed value of pattern parameter number, or null if not bound.
- * @param pS the fixed value of pattern parameter s, or null if not bound.
- * @param pC the fixed value of pattern parameter c, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public AverageNumberOfAttributes.Match newMatch(final Float pNumber, final Integer pS, final Integer pC) {
- return AverageNumberOfAttributes.Match.newMatch(pNumber, pS, pC);
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfnumber(final Object[] parameters) {
- return rawStreamAllValues(POSITION_NUMBER, parameters).map(Float.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfnumber() {
- return rawStreamAllValuesOfnumber(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfnumber() {
- return rawStreamAllValuesOfnumber(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- *
- * 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 streamAllValuesOfnumber(final AverageNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfnumber(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- *
- * 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 streamAllValuesOfnumber(final Integer pS, final Integer pC) {
- return rawStreamAllValuesOfnumber(new Object[]{null, pS, pC});
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfnumber(final AverageNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfnumber(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfnumber(final Integer pS, final Integer pC) {
- return rawStreamAllValuesOfnumber(new Object[]{null, pS, pC}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for s.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfs(final Object[] parameters) {
- return rawStreamAllValues(POSITION_S, parameters).map(Integer.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for s.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfs() {
- return rawStreamAllValuesOfs(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for s.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfs() {
- return rawStreamAllValuesOfs(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for s.
- *
- * 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 streamAllValuesOfs(final AverageNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfs(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for s.
- *
- * 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 streamAllValuesOfs(final Float pNumber, final Integer pC) {
- return rawStreamAllValuesOfs(new Object[]{pNumber, null, pC});
- }
-
- /**
- * Retrieve the set of values that occur in matches for s.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfs(final AverageNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfs(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for s.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfs(final Float pNumber, final Integer pC) {
- return rawStreamAllValuesOfs(new Object[]{pNumber, null, pC}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for c.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfc(final Object[] parameters) {
- return rawStreamAllValues(POSITION_C, parameters).map(Integer.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for c.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfc() {
- return rawStreamAllValuesOfc(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for c.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfc() {
- return rawStreamAllValuesOfc(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for c.
- *
- * 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 streamAllValuesOfc(final AverageNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfc(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for c.
- *
- * 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 streamAllValuesOfc(final Float pNumber, final Integer pS) {
- return rawStreamAllValuesOfc(new Object[]{pNumber, pS, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for c.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfc(final AverageNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfc(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for c.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfc(final Float pNumber, final Integer pS) {
- return rawStreamAllValuesOfc(new Object[]{pNumber, pS, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected AverageNumberOfAttributes.Match tupleToMatch(final Tuple t) {
- try {
- return AverageNumberOfAttributes.Match.newMatch((Float) t.get(POSITION_NUMBER), (Integer) t.get(POSITION_S), (Integer) t.get(POSITION_C));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected AverageNumberOfAttributes.Match arrayToMatch(final Object[] match) {
- try {
- return AverageNumberOfAttributes.Match.newMatch((Float) match[POSITION_NUMBER], (Integer) match[POSITION_S], (Integer) match[POSITION_C]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected AverageNumberOfAttributes.Match arrayToMatchMutable(final Object[] match) {
- try {
- return AverageNumberOfAttributes.Match.newMutableMatch((Float) match[POSITION_NUMBER], (Integer) match[POSITION_S], (Integer) match[POSITION_C]);
- } 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 AverageNumberOfAttributes.instance();
- }
- }
-
- private AverageNumberOfAttributes() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static AverageNumberOfAttributes instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected AverageNumberOfAttributes.Matcher instantiate(final ViatraQueryEngine engine) {
- return AverageNumberOfAttributes.Matcher.on(engine);
- }
-
- @Override
- public AverageNumberOfAttributes.Matcher instantiate() {
- return AverageNumberOfAttributes.Matcher.create();
- }
-
- @Override
- public AverageNumberOfAttributes.Match newEmptyMatch() {
- return AverageNumberOfAttributes.Match.newEmptyMatch();
- }
-
- @Override
- public AverageNumberOfAttributes.Match newMatch(final Object... parameters) {
- return AverageNumberOfAttributes.Match.newMatch((java.lang.Float) parameters[0], (java.lang.Integer) parameters[1], (java.lang.Integer) parameters[2]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.AverageNumberOfAttributes (visibility: PUBLIC, simpleName: AverageNumberOfAttributes, identifier: com.incquerylabs.v4md.test.queries.AverageNumberOfAttributes, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.AverageNumberOfAttributes (visibility: PUBLIC, simpleName: AverageNumberOfAttributes, identifier: com.incquerylabs.v4md.test.queries.AverageNumberOfAttributes, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static AverageNumberOfAttributes INSTANCE = new AverageNumberOfAttributes();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static AverageNumberOfAttributes.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_number = new PParameter("number", "java.lang.Float", new JavaTransitiveInstancesKey(java.lang.Float.class), PParameterDirection.INOUT);
-
- private final PParameter parameter_s = new PParameter("s", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT);
-
- private final PParameter parameter_c = new PParameter("c", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_number, parameter_s, parameter_c);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.averageNumberOfAttributes";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("number","s","c");
- }
-
- @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_number = body.getOrCreateVariableByName("number");
- PVariable var_s = body.getOrCreateVariableByName("s");
- PVariable var_c = body.getOrCreateVariableByName("c");
- PVariable var__c = body.getOrCreateVariableByName("_c");
- PVariable var__tempNumber = body.getOrCreateVariableByName("#tempNumber");
- PVariable var__c2 = body.getOrCreateVariableByName("_c2");
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_number), new JavaTransitiveInstancesKey(java.lang.Float.class));
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_s), new JavaTransitiveInstancesKey(java.lang.Integer.class));
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_c), new JavaTransitiveInstancesKey(java.lang.Integer.class));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_number, parameter_number),
- new ExportedParameter(body, var_s, parameter_s),
- new ExportedParameter(body, var_c, parameter_c)
- ));
- // //calculates sum s == sum find classNumberOfAttributes(_c, #tempNumber)
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new AggregatorConstraint(new sum().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var__c, var__tempNumber), ClassNumberOfAttributes.instance().getInternalQueryRepresentation(), var__virtual_0_, 1);
- new Equality(body, var_s, var__virtual_0_);
- // //determines the number of classes c == count find classes(_c2)
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new PatternMatchCounter(body, Tuples.flatTupleOf(var__c2), Classes.instance().getInternalQueryRepresentation(), var__virtual_1_);
- new Equality(body, var_c, var__virtual_1_);
- // //Calculates average in an eval() expression //similar to check() in an eval expression standard Java code can be used number == eval(s.floatValue/c.floatValue)
- PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
- new ExpressionEvaluation(body, new IExpressionEvaluator() {
-
- @Override
- public String getShortDescription() {
- return "Expression evaluation from pattern averageNumberOfAttributes";
- }
-
- @Override
- public Iterable getInputParameterNames() {
- return Arrays.asList("c", "s");}
-
- @Override
- public Object evaluateExpression(IValueProvider provider) throws Exception {
- Integer c = (Integer) provider.getValue("c");
- Integer s = (Integer) provider.getValue("s");
- return evaluateExpression_1_1(c, s);
- }
- }, var__virtual_2_ );
- new Equality(body, var_number, var__virtual_2_);
- bodies.add(body);
- }
- return bodies;
- }
- }
-
- private static float evaluateExpression_1_1(final Integer c, final Integer s) {
- float _floatValue = s.floatValue();
- float _floatValue_1 = c.floatValue();
- float _divide = (_floatValue / _floatValue_1);
- return _divide;
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Block_With_More_than_1_Parent.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Block_With_More_than_1_Parent.java
deleted file mode 100644
index 8ae4f57..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Block_With_More_than_1_Parent.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Block_With_More_than_1_Parent.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.BlocksWithDeepGeneralizationHierarchy;
-import com.incquerylabs.v4md.test.queries.GetSuperClasses;
-import com.incquerylabs.v4md.test.queries.MultipleInheritanceBlock;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
-
-/**
- * A pattern group formed of all public patterns defined in Block_With_More_than_1_Parent.vql.
- *
- * Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare
- * a VIATRA Query engine for matching all patterns originally defined in file Block_With_More_than_1_Parent.vql,
- * in order to achieve better performance than one-by-one on-demand matcher initialization.
- *
- *
From package com.incquerylabs.v4md.test.queries, the group contains the definition of the following patterns:
- * - BlocksWithDeepGeneralizationHierarchy
- * - MultipleInheritanceBlock
- * - getSuperClasses
- *
- *
- * @see IQueryGroup
- *
- */
-@SuppressWarnings("all")
-public final class Block_With_More_than_1_Parent extends BaseGeneratedPatternGroup {
- /**
- * Access the pattern group.
- *
- * @return the singleton instance of the group
- * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
- *
- */
- public static Block_With_More_than_1_Parent instance() {
- if (INSTANCE == null) {
- INSTANCE = new Block_With_More_than_1_Parent();
- }
- return INSTANCE;
- }
-
- private static Block_With_More_than_1_Parent INSTANCE;
-
- private Block_With_More_than_1_Parent() {
- querySpecifications.add(BlocksWithDeepGeneralizationHierarchy.instance());
- querySpecifications.add(MultipleInheritanceBlock.instance());
- querySpecifications.add(GetSuperClasses.instance());
- }
-
- public BlocksWithDeepGeneralizationHierarchy getBlocksWithDeepGeneralizationHierarchy() {
- return BlocksWithDeepGeneralizationHierarchy.instance();
- }
-
- public BlocksWithDeepGeneralizationHierarchy.Matcher getBlocksWithDeepGeneralizationHierarchy(final ViatraQueryEngine engine) {
- return BlocksWithDeepGeneralizationHierarchy.Matcher.on(engine);
- }
-
- public MultipleInheritanceBlock getMultipleInheritanceBlock() {
- return MultipleInheritanceBlock.instance();
- }
-
- public MultipleInheritanceBlock.Matcher getMultipleInheritanceBlock(final ViatraQueryEngine engine) {
- return MultipleInheritanceBlock.Matcher.on(engine);
- }
-
- public GetSuperClasses getGetSuperClasses() {
- return GetSuperClasses.instance();
- }
-
- public GetSuperClasses.Matcher getGetSuperClasses(final ViatraQueryEngine engine) {
- return GetSuperClasses.Matcher.on(engine);
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Blocks.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Blocks.java
deleted file mode 100644
index 8886506..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Blocks.java
+++ /dev/null
@@ -1,552 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Subpattern_Calls.vql
- */
-package com.incquerylabs.v4md.test.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:
- *
- * pattern blocks(class : Class){
- * //constraint that queries every class that has an instance of the "Block" stereotype
- * 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.v4md.test.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) {
- if ("class".equals(parameterName)) return this.fClass;
- 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.v4md.test.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.v4md.test.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:
- *
- * pattern blocks(class : Class){
- * //constraint that queries every class that has an instance of the "Block" stereotype
- * 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 final static int POSITION_CLASS = 0;
-
- private final static 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 JvmGenericType: com.incquerylabs.v4md.test.queries.Blocks (visibility: PUBLIC, simpleName: Blocks, identifier: com.incquerylabs.v4md.test.queries.Blocks, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.Blocks (visibility: PUBLIC, simpleName: Blocks, identifier: com.incquerylabs.v4md.test.queries.Blocks, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static 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.v4md.test.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)
- ));
- // //constraint that queries every class that has an instance of the "Block" stereotype 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.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/BlocksWithDeepGeneralizationHierarchy.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/BlocksWithDeepGeneralizationHierarchy.java
deleted file mode 100644
index 1e8477b..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/BlocksWithDeepGeneralizationHierarchy.java
+++ /dev/null
@@ -1,745 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Block_With_More_than_1_Parent.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.GetSuperClasses;
-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.basicdeferred.PatternMatchCounter;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
-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 BlocksWithDeepGeneralizationHierarchy(block : Class, superClass : Class) {
- * Class.appliedStereotypeInstance.classifier.name(block, "Block");
- * parents == count find getSuperClasses(block, _);
- * find getSuperClasses(block, superClass);
- * check(parents {@literal >} 1);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class BlocksWithDeepGeneralizationHierarchy extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.BlocksWithDeepGeneralizationHierarchy 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 fBlock;
-
- private com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class fSuperClass;
-
- private static List parameterNames = makeImmutableList("block", "superClass");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- this.fBlock = pBlock;
- this.fSuperClass = pSuperClass;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("block".equals(parameterName)) return this.fBlock;
- if ("superClass".equals(parameterName)) return this.fSuperClass;
- return null;
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getBlock() {
- return this.fBlock;
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getSuperClass() {
- return this.fSuperClass;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("block".equals(parameterName) ) {
- this.fBlock = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- if ("superClass".equals(parameterName) ) {
- this.fSuperClass = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- return false;
- }
-
- public void setBlock(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fBlock = pBlock;
- }
-
- public void setSuperClass(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fSuperClass = pSuperClass;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.BlocksWithDeepGeneralizationHierarchy";
- }
-
- @Override
- public List parameterNames() {
- return BlocksWithDeepGeneralizationHierarchy.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fBlock, fSuperClass};
- }
-
- @Override
- public BlocksWithDeepGeneralizationHierarchy.Match toImmutable() {
- return isMutable() ? newMatch(fBlock, fSuperClass) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"block\"=" + prettyPrintValue(fBlock) + ", ");
- result.append("\"superClass\"=" + prettyPrintValue(fSuperClass));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fBlock, fSuperClass);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof BlocksWithDeepGeneralizationHierarchy.Match)) {
- BlocksWithDeepGeneralizationHierarchy.Match other = (BlocksWithDeepGeneralizationHierarchy.Match) obj;
- return Objects.equals(fBlock, other.fBlock) && Objects.equals(fSuperClass, other.fSuperClass);
- } 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 BlocksWithDeepGeneralizationHierarchy specification() {
- return BlocksWithDeepGeneralizationHierarchy.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 BlocksWithDeepGeneralizationHierarchy.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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static BlocksWithDeepGeneralizationHierarchy.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- return new Mutable(pBlock, pSuperClass);
- }
-
- /**
- * 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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static BlocksWithDeepGeneralizationHierarchy.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- return new Immutable(pBlock, pSuperClass);
- }
-
- private static final class Mutable extends BlocksWithDeepGeneralizationHierarchy.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- super(pBlock, pSuperClass);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends BlocksWithDeepGeneralizationHierarchy.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- super(pBlock, pSuperClass);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.BlocksWithDeepGeneralizationHierarchy 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 BlocksWithDeepGeneralizationHierarchy(block : Class, superClass : Class) {
- * Class.appliedStereotypeInstance.classifier.name(block, "Block");
- * parents == count find getSuperClasses(block, _);
- * find getSuperClasses(block, superClass);
- * check(parents {@literal >} 1);
- * }
- *
- *
- * @see Match
- * @see BlocksWithDeepGeneralizationHierarchy
- *
- */
- 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 BlocksWithDeepGeneralizationHierarchy.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 BlocksWithDeepGeneralizationHierarchy.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_BLOCK = 0;
-
- private final static int POSITION_SUPERCLASS = 1;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(BlocksWithDeepGeneralizationHierarchy.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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- return rawStreamAllMatches(new Object[]{pBlock, pSuperClass}).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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, 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 pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- return rawStreamAllMatches(new Object[]{pBlock, pSuperClass});
- }
-
- /**
- * 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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, 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 pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- return rawGetOneArbitraryMatch(new Object[]{pBlock, pSuperClass});
- }
-
- /**
- * 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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, 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 pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- return rawHasMatch(new Object[]{pBlock, pSuperClass});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- return rawCountMatches(new Object[]{pBlock, pSuperClass});
- }
-
- /**
- * 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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, 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 pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass, final Consumer super BlocksWithDeepGeneralizationHierarchy.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pBlock, pSuperClass}, 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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public BlocksWithDeepGeneralizationHierarchy.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- return BlocksWithDeepGeneralizationHierarchy.Match.newMatch(pBlock, pSuperClass);
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfblock(final Object[] parameters) {
- return rawStreamAllValues(POSITION_BLOCK, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfblock() {
- return rawStreamAllValuesOfblock(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfblock() {
- return rawStreamAllValuesOfblock(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- *
- * 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 streamAllValuesOfblock(final BlocksWithDeepGeneralizationHierarchy.Match partialMatch) {
- return rawStreamAllValuesOfblock(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- *
- * 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 streamAllValuesOfblock(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- return rawStreamAllValuesOfblock(new Object[]{null, pSuperClass});
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfblock(final BlocksWithDeepGeneralizationHierarchy.Match partialMatch) {
- return rawStreamAllValuesOfblock(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfblock(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pSuperClass) {
- return rawStreamAllValuesOfblock(new Object[]{null, pSuperClass}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfsuperClass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_SUPERCLASS, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass() {
- return rawStreamAllValuesOfsuperClass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsuperClass() {
- return rawStreamAllValuesOfsuperClass(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- *
- * 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 streamAllValuesOfsuperClass(final BlocksWithDeepGeneralizationHierarchy.Match partialMatch) {
- return rawStreamAllValuesOfsuperClass(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- *
- * 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 streamAllValuesOfsuperClass(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock) {
- return rawStreamAllValuesOfsuperClass(new Object[]{pBlock, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass(final BlocksWithDeepGeneralizationHierarchy.Match partialMatch) {
- return rawStreamAllValuesOfsuperClass(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock) {
- return rawStreamAllValuesOfsuperClass(new Object[]{pBlock, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected BlocksWithDeepGeneralizationHierarchy.Match tupleToMatch(final Tuple t) {
- try {
- return BlocksWithDeepGeneralizationHierarchy.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_BLOCK), (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_SUPERCLASS));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected BlocksWithDeepGeneralizationHierarchy.Match arrayToMatch(final Object[] match) {
- try {
- return BlocksWithDeepGeneralizationHierarchy.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_BLOCK], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_SUPERCLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected BlocksWithDeepGeneralizationHierarchy.Match arrayToMatchMutable(final Object[] match) {
- try {
- return BlocksWithDeepGeneralizationHierarchy.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_BLOCK], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_SUPERCLASS]);
- } 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 BlocksWithDeepGeneralizationHierarchy.instance();
- }
- }
-
- private BlocksWithDeepGeneralizationHierarchy() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static BlocksWithDeepGeneralizationHierarchy instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected BlocksWithDeepGeneralizationHierarchy.Matcher instantiate(final ViatraQueryEngine engine) {
- return BlocksWithDeepGeneralizationHierarchy.Matcher.on(engine);
- }
-
- @Override
- public BlocksWithDeepGeneralizationHierarchy.Matcher instantiate() {
- return BlocksWithDeepGeneralizationHierarchy.Matcher.create();
- }
-
- @Override
- public BlocksWithDeepGeneralizationHierarchy.Match newEmptyMatch() {
- return BlocksWithDeepGeneralizationHierarchy.Match.newEmptyMatch();
- }
-
- @Override
- public BlocksWithDeepGeneralizationHierarchy.Match newMatch(final Object... parameters) {
- return BlocksWithDeepGeneralizationHierarchy.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.BlocksWithDeepGeneralizationHierarchy (visibility: PUBLIC, simpleName: BlocksWithDeepGeneralizationHierarchy, identifier: com.incquerylabs.v4md.test.queries.BlocksWithDeepGeneralizationHierarchy, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.BlocksWithDeepGeneralizationHierarchy (visibility: PUBLIC, simpleName: BlocksWithDeepGeneralizationHierarchy, identifier: com.incquerylabs.v4md.test.queries.BlocksWithDeepGeneralizationHierarchy, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static BlocksWithDeepGeneralizationHierarchy INSTANCE = new BlocksWithDeepGeneralizationHierarchy();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static BlocksWithDeepGeneralizationHierarchy.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_block = new PParameter("block", "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 PParameter parameter_superClass = new PParameter("superClass", "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_block, parameter_superClass);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.BlocksWithDeepGeneralizationHierarchy";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("block","superClass");
- }
-
- @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_block = body.getOrCreateVariableByName("block");
- PVariable var_superClass = body.getOrCreateVariableByName("superClass");
- PVariable var_parents = body.getOrCreateVariableByName("parents");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- new TypeConstraint(body, Tuples.flatTupleOf(var_block), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_superClass), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_block, parameter_block),
- new ExportedParameter(body, var_superClass, parameter_superClass)
- ));
- // Class.appliedStereotypeInstance.classifier.name(block, "Block")
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new ConstantValue(body, var__virtual_0_, "Block");
- new TypeConstraint(body, Tuples.flatTupleOf(var_block), 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_block, 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_);
- // parents == count find getSuperClasses(block, _)
- PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}");
- new PatternMatchCounter(body, Tuples.flatTupleOf(var_block, var___0_), GetSuperClasses.instance().getInternalQueryRepresentation(), var__virtual_4_);
- new Equality(body, var_parents, var__virtual_4_);
- // find getSuperClasses(block, superClass)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_block, var_superClass), GetSuperClasses.instance().getInternalQueryRepresentation());
- // check(parents > 1)
- new ExpressionEvaluation(body, new IExpressionEvaluator() {
-
- @Override
- public String getShortDescription() {
- return "Expression evaluation from pattern BlocksWithDeepGeneralizationHierarchy";
- }
-
- @Override
- public Iterable getInputParameterNames() {
- return Arrays.asList("parents");}
-
- @Override
- public Object evaluateExpression(IValueProvider provider) throws Exception {
- Integer parents = (Integer) provider.getValue("parents");
- return evaluateExpression_1_1(parents);
- }
- }, null);
- bodies.add(body);
- }
- return bodies;
- }
- }
-
- private static boolean evaluateExpression_1_1(final Integer parents) {
- return ((parents).intValue() > 1);
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/BlocksWithNonEmptyName.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/BlocksWithNonEmptyName.java
deleted file mode 100644
index e4b3614..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/BlocksWithNonEmptyName.java
+++ /dev/null
@@ -1,551 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Subpattern_Calls.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.Blocks;
-import com.incquerylabs.v4md.test.queries.ClassesWithEmptyName;
-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:
- *
- * //Main pattern that queries every block in the model with a non emty name
- * //Note that you dont need to check the subpatterns to be able to execute the main query,
- * // as during runtime queries are flattened, meaning that subpattern calls are replaced with the body of the called query
- * pattern blocksWithNonEmptyName(class : Class){
- * //Filter for block
- * find blocks(class);
- * //Negative subpattern call --{@literal >} true for classes that do not have an empty name
- * neg find classesWithEmptyName(class);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class BlocksWithNonEmptyName extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.blocksWithNonEmptyName 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) {
- if ("class".equals(parameterName)) return this.fClass;
- 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.v4md.test.queries.blocksWithNonEmptyName";
- }
-
- @Override
- public List parameterNames() {
- return BlocksWithNonEmptyName.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass};
- }
-
- @Override
- public BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.Match)) {
- BlocksWithNonEmptyName.Match other = (BlocksWithNonEmptyName.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 BlocksWithNonEmptyName specification() {
- return BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Immutable(pClass);
- }
-
- private static final class Mutable extends BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.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.v4md.test.queries.blocksWithNonEmptyName 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:
- *
- * //Main pattern that queries every block in the model with a non emty name
- * //Note that you dont need to check the subpatterns to be able to execute the main query,
- * // as during runtime queries are flattened, meaning that subpattern calls are replaced with the body of the called query
- * pattern blocksWithNonEmptyName(class : Class){
- * //Filter for block
- * find blocks(class);
- * //Negative subpattern call --{@literal >} true for classes that do not have an empty name
- * neg find classesWithEmptyName(class);
- * }
- *
- *
- * @see Match
- * @see BlocksWithNonEmptyName
- *
- */
- 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 BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_CLASS = 0;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.Match tupleToMatch(final Tuple t) {
- try {
- return BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.Match arrayToMatch(final Object[] match) {
- try {
- return BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.Match arrayToMatchMutable(final Object[] match) {
- try {
- return BlocksWithNonEmptyName.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 BlocksWithNonEmptyName.instance();
- }
- }
-
- private BlocksWithNonEmptyName() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static BlocksWithNonEmptyName instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected BlocksWithNonEmptyName.Matcher instantiate(final ViatraQueryEngine engine) {
- return BlocksWithNonEmptyName.Matcher.on(engine);
- }
-
- @Override
- public BlocksWithNonEmptyName.Matcher instantiate() {
- return BlocksWithNonEmptyName.Matcher.create();
- }
-
- @Override
- public BlocksWithNonEmptyName.Match newEmptyMatch() {
- return BlocksWithNonEmptyName.Match.newEmptyMatch();
- }
-
- @Override
- public BlocksWithNonEmptyName.Match newMatch(final Object... parameters) {
- return BlocksWithNonEmptyName.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.BlocksWithNonEmptyName (visibility: PUBLIC, simpleName: BlocksWithNonEmptyName, identifier: com.incquerylabs.v4md.test.queries.BlocksWithNonEmptyName, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.BlocksWithNonEmptyName (visibility: PUBLIC, simpleName: BlocksWithNonEmptyName, identifier: com.incquerylabs.v4md.test.queries.BlocksWithNonEmptyName, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static BlocksWithNonEmptyName INSTANCE = new BlocksWithNonEmptyName();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static BlocksWithNonEmptyName.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.v4md.test.queries.blocksWithNonEmptyName";
- }
-
- @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)
- ));
- // //Filter for block find blocks(class)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_class), Blocks.instance().getInternalQueryRepresentation());
- // //Negative subpattern call --> true for classes that do not have an empty name neg find classesWithEmptyName(class)
- new NegativePatternCall(body, Tuples.flatTupleOf(var_class), ClassesWithEmptyName.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Check_Expression.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Check_Expression.java
deleted file mode 100644
index afbac3c..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Check_Expression.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Check_Expression.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.ClassesWithNameThatContainsID;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
-
-/**
- * A pattern group formed of all public patterns defined in Check_Expression.vql.
- *
- * Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare
- * a VIATRA Query engine for matching all patterns originally defined in file Check_Expression.vql,
- * in order to achieve better performance than one-by-one on-demand matcher initialization.
- *
- *
From package com.incquerylabs.v4md.test.queries, the group contains the definition of the following patterns:
- * - classesWithNameThatContainsID
- *
- *
- * @see IQueryGroup
- *
- */
-@SuppressWarnings("all")
-public final class Check_Expression extends BaseGeneratedPatternGroup {
- /**
- * Access the pattern group.
- *
- * @return the singleton instance of the group
- * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
- *
- */
- public static Check_Expression instance() {
- if (INSTANCE == null) {
- INSTANCE = new Check_Expression();
- }
- return INSTANCE;
- }
-
- private static Check_Expression INSTANCE;
-
- private Check_Expression() {
- querySpecifications.add(ClassesWithNameThatContainsID.instance());
- }
-
- public ClassesWithNameThatContainsID getClassesWithNameThatContainsID() {
- return ClassesWithNameThatContainsID.instance();
- }
-
- public ClassesWithNameThatContainsID.Matcher getClassesWithNameThatContainsID(final ViatraQueryEngine engine) {
- return ClassesWithNameThatContainsID.Matcher.on(engine);
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/CircularDependencyError.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/CircularDependencyError.java
deleted file mode 100644
index c32847f..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/CircularDependencyError.java
+++ /dev/null
@@ -1,542 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Circular_Dependency.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.DependencyChain;
-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 in UML models
- *
- * pattern CircularDependencyError(dep : Dependency) {
- * //Call transitive closure of sub-pattern 'DependencyChain'
- * find DependencyChain+(dep, dep);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class CircularDependencyError extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.CircularDependencyError 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 fDep;
-
- private static List parameterNames = makeImmutableList("dep");
-
- private Match(final Dependency pDep) {
- this.fDep = pDep;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("dep".equals(parameterName)) return this.fDep;
- return null;
- }
-
- public Dependency getDep() {
- return this.fDep;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("dep".equals(parameterName) ) {
- this.fDep = (Dependency) newValue;
- return true;
- }
- return false;
- }
-
- public void setDep(final Dependency pDep) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fDep = pDep;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.CircularDependencyError";
- }
-
- @Override
- public List parameterNames() {
- return CircularDependencyError.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fDep};
- }
-
- @Override
- public CircularDependencyError.Match toImmutable() {
- return isMutable() ? newMatch(fDep) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"dep\"=" + prettyPrintValue(fDep));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fDep);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof CircularDependencyError.Match)) {
- CircularDependencyError.Match other = (CircularDependencyError.Match) obj;
- return Objects.equals(fDep, other.fDep);
- } 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 CircularDependencyError specification() {
- return CircularDependencyError.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 CircularDependencyError.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 pDep the fixed value of pattern parameter dep, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static CircularDependencyError.Match newMutableMatch(final Dependency pDep) {
- return new Mutable(pDep);
- }
-
- /**
- * 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 pDep the fixed value of pattern parameter dep, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static CircularDependencyError.Match newMatch(final Dependency pDep) {
- return new Immutable(pDep);
- }
-
- private static final class Mutable extends CircularDependencyError.Match {
- Mutable(final Dependency pDep) {
- super(pDep);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends CircularDependencyError.Match {
- Immutable(final Dependency pDep) {
- super(pDep);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.CircularDependencyError 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 in UML models
- *
- * pattern CircularDependencyError(dep : Dependency) {
- * //Call transitive closure of sub-pattern 'DependencyChain'
- * find DependencyChain+(dep, dep);
- * }
- *
- *
- * @see Match
- * @see CircularDependencyError
- *
- */
- 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 CircularDependencyError.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 CircularDependencyError.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_DEP = 0;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CircularDependencyError.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 pDep the fixed value of pattern parameter dep, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final Dependency pDep) {
- return rawStreamAllMatches(new Object[]{pDep}).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 pDep the fixed value of pattern parameter dep, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final Dependency pDep) {
- return rawStreamAllMatches(new Object[]{pDep});
- }
-
- /**
- * 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 pDep the fixed value of pattern parameter dep, 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 pDep) {
- return rawGetOneArbitraryMatch(new Object[]{pDep});
- }
-
- /**
- * 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 pDep the fixed value of pattern parameter dep, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final Dependency pDep) {
- return rawHasMatch(new Object[]{pDep});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pDep the fixed value of pattern parameter dep, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final Dependency pDep) {
- return rawCountMatches(new Object[]{pDep});
- }
-
- /**
- * 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 pDep the fixed value of pattern parameter dep, 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 pDep, final Consumer super CircularDependencyError.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pDep}, 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 pDep the fixed value of pattern parameter dep, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public CircularDependencyError.Match newMatch(final Dependency pDep) {
- return CircularDependencyError.Match.newMatch(pDep);
- }
-
- /**
- * Retrieve the set of values that occur in matches for dep.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfdep(final Object[] parameters) {
- return rawStreamAllValues(POSITION_DEP, parameters).map(Dependency.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for dep.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfdep() {
- return rawStreamAllValuesOfdep(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for dep.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfdep() {
- return rawStreamAllValuesOfdep(emptyArray());
- }
-
- @Override
- protected CircularDependencyError.Match tupleToMatch(final Tuple t) {
- try {
- return CircularDependencyError.Match.newMatch((Dependency) t.get(POSITION_DEP));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected CircularDependencyError.Match arrayToMatch(final Object[] match) {
- try {
- return CircularDependencyError.Match.newMatch((Dependency) match[POSITION_DEP]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected CircularDependencyError.Match arrayToMatchMutable(final Object[] match) {
- try {
- return CircularDependencyError.Match.newMutableMatch((Dependency) match[POSITION_DEP]);
- } 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 CircularDependencyError.instance();
- }
- }
-
- private CircularDependencyError() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static CircularDependencyError instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected CircularDependencyError.Matcher instantiate(final ViatraQueryEngine engine) {
- return CircularDependencyError.Matcher.on(engine);
- }
-
- @Override
- public CircularDependencyError.Matcher instantiate() {
- return CircularDependencyError.Matcher.create();
- }
-
- @Override
- public CircularDependencyError.Match newEmptyMatch() {
- return CircularDependencyError.Match.newEmptyMatch();
- }
-
- @Override
- public CircularDependencyError.Match newMatch(final Object... parameters) {
- return CircularDependencyError.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mddependencies.Dependency) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.CircularDependencyError (visibility: PUBLIC, simpleName: CircularDependencyError, identifier: com.incquerylabs.v4md.test.queries.CircularDependencyError, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.CircularDependencyError (visibility: PUBLIC, simpleName: CircularDependencyError, identifier: com.incquerylabs.v4md.test.queries.CircularDependencyError, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static CircularDependencyError INSTANCE = new CircularDependencyError();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static CircularDependencyError.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_dep = new PParameter("dep", "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_dep);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.CircularDependencyError";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("dep");
- }
-
- @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_dep = body.getOrCreateVariableByName("dep");
- new TypeConstraint(body, Tuples.flatTupleOf(var_dep), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Dependency")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_dep, parameter_dep)
- ));
- // //Call transitive closure of sub-pattern 'DependencyChain' find DependencyChain+(dep, dep)
- new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_dep, var_dep), DependencyChain.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Circular_Dependency.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Circular_Dependency.java
deleted file mode 100644
index c5fce5c..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Circular_Dependency.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Circular_Dependency.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.CircularDependencyError;
-import com.incquerylabs.v4md.test.queries.DependencyChain;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
-
-/**
- * A pattern group formed of all public patterns defined in Circular_Dependency.vql.
- *
- * Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare
- * a VIATRA Query engine for matching all patterns originally defined in file Circular_Dependency.vql,
- * in order to achieve better performance than one-by-one on-demand matcher initialization.
- *
- *
From package com.incquerylabs.v4md.test.queries, the group contains the definition of the following patterns:
- * - CircularDependencyError
- * - DependencyChain
- *
- *
- * @see IQueryGroup
- *
- */
-@SuppressWarnings("all")
-public final class Circular_Dependency extends BaseGeneratedPatternGroup {
- /**
- * Access the pattern group.
- *
- * @return the singleton instance of the group
- * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
- *
- */
- public static Circular_Dependency instance() {
- if (INSTANCE == null) {
- INSTANCE = new Circular_Dependency();
- }
- return INSTANCE;
- }
-
- private static Circular_Dependency INSTANCE;
-
- private Circular_Dependency() {
- querySpecifications.add(CircularDependencyError.instance());
- querySpecifications.add(DependencyChain.instance());
- }
-
- public CircularDependencyError getCircularDependencyError() {
- return CircularDependencyError.instance();
- }
-
- public CircularDependencyError.Matcher getCircularDependencyError(final ViatraQueryEngine engine) {
- return CircularDependencyError.Matcher.on(engine);
- }
-
- public DependencyChain getDependencyChain() {
- return DependencyChain.instance();
- }
-
- public DependencyChain.Matcher getDependencyChain(final ViatraQueryEngine engine) {
- return DependencyChain.Matcher.on(engine);
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassAttributes.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassAttributes.java
deleted file mode 100644
index 5d52a42..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassAttributes.java
+++ /dev/null
@@ -1,695 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Aggregator_Functions.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property;
-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:
- *
- * //Maps classes to their owned properties
- * pattern classAttributes(class : Class, attribute : Property){
- * Class.ownedAttribute(class, attribute);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class ClassAttributes extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.classAttributes 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 Property fAttribute;
-
- private static List parameterNames = makeImmutableList("class", "attribute");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Property pAttribute) {
- this.fClass = pClass;
- this.fAttribute = pAttribute;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("class".equals(parameterName)) return this.fClass;
- if ("attribute".equals(parameterName)) return this.fAttribute;
- return null;
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getValueOfClass() {
- return this.fClass;
- }
-
- public Property getAttribute() {
- return this.fAttribute;
- }
-
- @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;
- }
- if ("attribute".equals(parameterName) ) {
- this.fAttribute = (Property) 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;
- }
-
- public void setAttribute(final Property pAttribute) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fAttribute = pAttribute;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.classAttributes";
- }
-
- @Override
- public List parameterNames() {
- return ClassAttributes.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass, fAttribute};
- }
-
- @Override
- public ClassAttributes.Match toImmutable() {
- return isMutable() ? newMatch(fClass, fAttribute) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass) + ", ");
- result.append("\"attribute\"=" + prettyPrintValue(fAttribute));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass, fAttribute);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof ClassAttributes.Match)) {
- ClassAttributes.Match other = (ClassAttributes.Match) obj;
- return Objects.equals(fClass, other.fClass) && Objects.equals(fAttribute, other.fAttribute);
- } 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 ClassAttributes specification() {
- return ClassAttributes.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 ClassAttributes.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 pClass the fixed value of pattern parameter class, or null if not bound.
- * @param pAttribute the fixed value of pattern parameter attribute, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static ClassAttributes.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Property pAttribute) {
- return new Mutable(pClass, pAttribute);
- }
-
- /**
- * 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.
- * @param pAttribute the fixed value of pattern parameter attribute, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static ClassAttributes.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Property pAttribute) {
- return new Immutable(pClass, pAttribute);
- }
-
- private static final class Mutable extends ClassAttributes.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Property pAttribute) {
- super(pClass, pAttribute);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends ClassAttributes.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Property pAttribute) {
- super(pClass, pAttribute);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.classAttributes 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:
- *
- * //Maps classes to their owned properties
- * pattern classAttributes(class : Class, attribute : Property){
- * Class.ownedAttribute(class, attribute);
- * }
- *
- *
- * @see Match
- * @see ClassAttributes
- *
- */
- 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 ClassAttributes.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 ClassAttributes.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_CLASS = 0;
-
- private final static int POSITION_ATTRIBUTE = 1;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ClassAttributes.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.
- * @param pAttribute the fixed value of pattern parameter attribute, 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, final Property pAttribute) {
- return rawStreamAllMatches(new Object[]{pClass, pAttribute}).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.
- * @param pAttribute the fixed value of pattern parameter attribute, 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, final Property pAttribute) {
- return rawStreamAllMatches(new Object[]{pClass, pAttribute});
- }
-
- /**
- * 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.
- * @param pAttribute the fixed value of pattern parameter attribute, 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, final Property pAttribute) {
- return rawGetOneArbitraryMatch(new Object[]{pClass, pAttribute});
- }
-
- /**
- * 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.
- * @param pAttribute the fixed value of pattern parameter attribute, 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, final Property pAttribute) {
- return rawHasMatch(new Object[]{pClass, pAttribute});
- }
-
- /**
- * 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.
- * @param pAttribute the fixed value of pattern parameter attribute, 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, final Property pAttribute) {
- return rawCountMatches(new Object[]{pClass, pAttribute});
- }
-
- /**
- * 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 pAttribute the fixed value of pattern parameter attribute, 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 Property pAttribute, final Consumer super ClassAttributes.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass, pAttribute}, 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.
- * @param pAttribute the fixed value of pattern parameter attribute, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public ClassAttributes.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Property pAttribute) {
- return ClassAttributes.Match.newMatch(pClass, pAttribute);
- }
-
- /**
- * 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());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final ClassAttributes.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final Property pAttribute) {
- return rawStreamAllValuesOfclass(new Object[]{null, pAttribute});
- }
-
- /**
- * 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(final ClassAttributes.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray()).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 Set getAllValuesOfclass(final Property pAttribute) {
- return rawStreamAllValuesOfclass(new Object[]{null, pAttribute}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for attribute.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfattribute(final Object[] parameters) {
- return rawStreamAllValues(POSITION_ATTRIBUTE, parameters).map(Property.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for attribute.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfattribute() {
- return rawStreamAllValuesOfattribute(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for attribute.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfattribute() {
- return rawStreamAllValuesOfattribute(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for attribute.
- *
- * 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 streamAllValuesOfattribute(final ClassAttributes.Match partialMatch) {
- return rawStreamAllValuesOfattribute(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for attribute.
- *
- * 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 streamAllValuesOfattribute(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllValuesOfattribute(new Object[]{pClass, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for attribute.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfattribute(final ClassAttributes.Match partialMatch) {
- return rawStreamAllValuesOfattribute(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for attribute.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfattribute(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllValuesOfattribute(new Object[]{pClass, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected ClassAttributes.Match tupleToMatch(final Tuple t) {
- try {
- return ClassAttributes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_CLASS), (Property) t.get(POSITION_ATTRIBUTE));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ClassAttributes.Match arrayToMatch(final Object[] match) {
- try {
- return ClassAttributes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS], (Property) match[POSITION_ATTRIBUTE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ClassAttributes.Match arrayToMatchMutable(final Object[] match) {
- try {
- return ClassAttributes.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS], (Property) match[POSITION_ATTRIBUTE]);
- } 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 ClassAttributes.instance();
- }
- }
-
- private ClassAttributes() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ClassAttributes instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected ClassAttributes.Matcher instantiate(final ViatraQueryEngine engine) {
- return ClassAttributes.Matcher.on(engine);
- }
-
- @Override
- public ClassAttributes.Matcher instantiate() {
- return ClassAttributes.Matcher.create();
- }
-
- @Override
- public ClassAttributes.Match newEmptyMatch() {
- return ClassAttributes.Match.newEmptyMatch();
- }
-
- @Override
- public ClassAttributes.Match newMatch(final Object... parameters) {
- return ClassAttributes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassAttributes (visibility: PUBLIC, simpleName: ClassAttributes, identifier: com.incquerylabs.v4md.test.queries.ClassAttributes, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassAttributes (visibility: PUBLIC, simpleName: ClassAttributes, identifier: com.incquerylabs.v4md.test.queries.ClassAttributes, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static ClassAttributes INSTANCE = new ClassAttributes();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static ClassAttributes.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 PParameter parameter_attribute = new PParameter("attribute", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Property")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class, parameter_attribute);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.classAttributes";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class","attribute");
- }
-
- @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_attribute = body.getOrCreateVariableByName("attribute");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_attribute), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Property")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class),
- new ExportedParameter(body, var_attribute, parameter_attribute)
- ));
- // Class.ownedAttribute(class, attribute)
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- 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", "StructuredClassifier", "ownedAttribute")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Property")));
- new Equality(body, var__virtual_0_, var_attribute);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassNumberOfAttributes.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassNumberOfAttributes.java
deleted file mode 100644
index 3a1eef9..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassNumberOfAttributes.java
+++ /dev/null
@@ -1,698 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Aggregator_Functions.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.ClassAttributes;
-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:
- *
- * //Counts the number of properties of classes
- * pattern classNumberOfAttributes(class : Class, number : java Integer){
- * //Counts the number of matches of 'classAttributes' for each class
- * number == count find classAttributes(class, _);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class ClassNumberOfAttributes extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.classNumberOfAttributes 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 Integer fNumber;
-
- private static List parameterNames = makeImmutableList("class", "number");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- this.fClass = pClass;
- this.fNumber = pNumber;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("class".equals(parameterName)) return this.fClass;
- if ("number".equals(parameterName)) return this.fNumber;
- return null;
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getValueOfClass() {
- return this.fClass;
- }
-
- public Integer getNumber() {
- return this.fNumber;
- }
-
- @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;
- }
- if ("number".equals(parameterName) ) {
- this.fNumber = (Integer) 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;
- }
-
- public void setNumber(final Integer pNumber) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fNumber = pNumber;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.classNumberOfAttributes";
- }
-
- @Override
- public List parameterNames() {
- return ClassNumberOfAttributes.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass, fNumber};
- }
-
- @Override
- public ClassNumberOfAttributes.Match toImmutable() {
- return isMutable() ? newMatch(fClass, fNumber) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass) + ", ");
- result.append("\"number\"=" + prettyPrintValue(fNumber));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass, fNumber);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof ClassNumberOfAttributes.Match)) {
- ClassNumberOfAttributes.Match other = (ClassNumberOfAttributes.Match) obj;
- return Objects.equals(fClass, other.fClass) && Objects.equals(fNumber, other.fNumber);
- } 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 ClassNumberOfAttributes specification() {
- return ClassNumberOfAttributes.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 ClassNumberOfAttributes.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 pClass the fixed value of pattern parameter class, or null if not bound.
- * @param pNumber the fixed value of pattern parameter number, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static ClassNumberOfAttributes.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- return new Mutable(pClass, pNumber);
- }
-
- /**
- * 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.
- * @param pNumber the fixed value of pattern parameter number, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static ClassNumberOfAttributes.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- return new Immutable(pClass, pNumber);
- }
-
- private static final class Mutable extends ClassNumberOfAttributes.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- super(pClass, pNumber);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends ClassNumberOfAttributes.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- super(pClass, pNumber);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.classNumberOfAttributes 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:
- *
- * //Counts the number of properties of classes
- * pattern classNumberOfAttributes(class : Class, number : java Integer){
- * //Counts the number of matches of 'classAttributes' for each class
- * number == count find classAttributes(class, _);
- * }
- *
- *
- * @see Match
- * @see ClassNumberOfAttributes
- *
- */
- 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 ClassNumberOfAttributes.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 ClassNumberOfAttributes.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_CLASS = 0;
-
- private final static int POSITION_NUMBER = 1;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ClassNumberOfAttributes.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.
- * @param pNumber the fixed value of pattern parameter number, 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, final Integer pNumber) {
- return rawStreamAllMatches(new Object[]{pClass, pNumber}).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.
- * @param pNumber the fixed value of pattern parameter number, 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, final Integer pNumber) {
- return rawStreamAllMatches(new Object[]{pClass, pNumber});
- }
-
- /**
- * 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.
- * @param pNumber the fixed value of pattern parameter number, 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, final Integer pNumber) {
- return rawGetOneArbitraryMatch(new Object[]{pClass, pNumber});
- }
-
- /**
- * 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.
- * @param pNumber the fixed value of pattern parameter number, 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, final Integer pNumber) {
- return rawHasMatch(new Object[]{pClass, pNumber});
- }
-
- /**
- * 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.
- * @param pNumber the fixed value of pattern parameter number, 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, final Integer pNumber) {
- return rawCountMatches(new Object[]{pClass, pNumber});
- }
-
- /**
- * 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 pNumber the fixed value of pattern parameter number, 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 Integer pNumber, final Consumer super ClassNumberOfAttributes.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass, pNumber}, 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.
- * @param pNumber the fixed value of pattern parameter number, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public ClassNumberOfAttributes.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- return ClassNumberOfAttributes.Match.newMatch(pClass, pNumber);
- }
-
- /**
- * 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());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final ClassNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final Integer pNumber) {
- return rawStreamAllValuesOfclass(new Object[]{null, pNumber});
- }
-
- /**
- * 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(final ClassNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray()).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 Set getAllValuesOfclass(final Integer pNumber) {
- return rawStreamAllValuesOfclass(new Object[]{null, pNumber}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfnumber(final Object[] parameters) {
- return rawStreamAllValues(POSITION_NUMBER, parameters).map(Integer.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfnumber() {
- return rawStreamAllValuesOfnumber(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfnumber() {
- return rawStreamAllValuesOfnumber(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- *
- * 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 streamAllValuesOfnumber(final ClassNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfnumber(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- *
- * 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 streamAllValuesOfnumber(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllValuesOfnumber(new Object[]{pClass, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfnumber(final ClassNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfnumber(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfnumber(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllValuesOfnumber(new Object[]{pClass, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected ClassNumberOfAttributes.Match tupleToMatch(final Tuple t) {
- try {
- return ClassNumberOfAttributes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_CLASS), (Integer) t.get(POSITION_NUMBER));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ClassNumberOfAttributes.Match arrayToMatch(final Object[] match) {
- try {
- return ClassNumberOfAttributes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS], (Integer) match[POSITION_NUMBER]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ClassNumberOfAttributes.Match arrayToMatchMutable(final Object[] match) {
- try {
- return ClassNumberOfAttributes.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS], (Integer) match[POSITION_NUMBER]);
- } 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 ClassNumberOfAttributes.instance();
- }
- }
-
- private ClassNumberOfAttributes() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ClassNumberOfAttributes instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected ClassNumberOfAttributes.Matcher instantiate(final ViatraQueryEngine engine) {
- return ClassNumberOfAttributes.Matcher.on(engine);
- }
-
- @Override
- public ClassNumberOfAttributes.Matcher instantiate() {
- return ClassNumberOfAttributes.Matcher.create();
- }
-
- @Override
- public ClassNumberOfAttributes.Match newEmptyMatch() {
- return ClassNumberOfAttributes.Match.newEmptyMatch();
- }
-
- @Override
- public ClassNumberOfAttributes.Match newMatch(final Object... parameters) {
- return ClassNumberOfAttributes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0], (java.lang.Integer) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassNumberOfAttributes (visibility: PUBLIC, simpleName: ClassNumberOfAttributes, identifier: com.incquerylabs.v4md.test.queries.ClassNumberOfAttributes, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassNumberOfAttributes (visibility: PUBLIC, simpleName: ClassNumberOfAttributes, identifier: com.incquerylabs.v4md.test.queries.ClassNumberOfAttributes, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static ClassNumberOfAttributes INSTANCE = new ClassNumberOfAttributes();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static ClassNumberOfAttributes.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 PParameter parameter_number = new PParameter("number", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class, parameter_number);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.classNumberOfAttributes";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class","number");
- }
-
- @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_number = body.getOrCreateVariableByName("number");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_number), new JavaTransitiveInstancesKey(java.lang.Integer.class));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class),
- new ExportedParameter(body, var_number, parameter_number)
- ));
- // //Counts the number of matches of 'classAttributes' for each class number == count find classAttributes(class, _)
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new PatternMatchCounter(body, Tuples.flatTupleOf(var_class, var___0_), ClassAttributes.instance().getInternalQueryRepresentation(), var__virtual_0_);
- new Equality(body, var_number, var__virtual_0_);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassWithMaxNumberOfAttributes.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassWithMaxNumberOfAttributes.java
deleted file mode 100644
index 70a8c31..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassWithMaxNumberOfAttributes.java
+++ /dev/null
@@ -1,711 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Aggregator_Functions.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.ClassNumberOfAttributes;
-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.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.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.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:
- *
- * //Queries the class with the most number of attributes
- * pattern classWithMaxNumberOfAttributes(class : Class, number : java Integer) {
- * //Calculates the largest class number
- * //Note use # to determine which parameter should be used for aggregation
- * //in this case to calculate max
- * number == max find classNumberOfAttributes(_, #tempNumber);
- * //Queries the class with the highest number
- * find classNumberOfAttributes(class, number);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class ClassWithMaxNumberOfAttributes extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.classWithMaxNumberOfAttributes 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 Integer fNumber;
-
- private static List parameterNames = makeImmutableList("class", "number");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- this.fClass = pClass;
- this.fNumber = pNumber;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("class".equals(parameterName)) return this.fClass;
- if ("number".equals(parameterName)) return this.fNumber;
- return null;
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getValueOfClass() {
- return this.fClass;
- }
-
- public Integer getNumber() {
- return this.fNumber;
- }
-
- @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;
- }
- if ("number".equals(parameterName) ) {
- this.fNumber = (Integer) 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;
- }
-
- public void setNumber(final Integer pNumber) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fNumber = pNumber;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.classWithMaxNumberOfAttributes";
- }
-
- @Override
- public List parameterNames() {
- return ClassWithMaxNumberOfAttributes.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass, fNumber};
- }
-
- @Override
- public ClassWithMaxNumberOfAttributes.Match toImmutable() {
- return isMutable() ? newMatch(fClass, fNumber) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass) + ", ");
- result.append("\"number\"=" + prettyPrintValue(fNumber));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass, fNumber);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof ClassWithMaxNumberOfAttributes.Match)) {
- ClassWithMaxNumberOfAttributes.Match other = (ClassWithMaxNumberOfAttributes.Match) obj;
- return Objects.equals(fClass, other.fClass) && Objects.equals(fNumber, other.fNumber);
- } 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 ClassWithMaxNumberOfAttributes specification() {
- return ClassWithMaxNumberOfAttributes.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 ClassWithMaxNumberOfAttributes.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 pClass the fixed value of pattern parameter class, or null if not bound.
- * @param pNumber the fixed value of pattern parameter number, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static ClassWithMaxNumberOfAttributes.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- return new Mutable(pClass, pNumber);
- }
-
- /**
- * 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.
- * @param pNumber the fixed value of pattern parameter number, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static ClassWithMaxNumberOfAttributes.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- return new Immutable(pClass, pNumber);
- }
-
- private static final class Mutable extends ClassWithMaxNumberOfAttributes.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- super(pClass, pNumber);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends ClassWithMaxNumberOfAttributes.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- super(pClass, pNumber);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.classWithMaxNumberOfAttributes 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:
- *
- * //Queries the class with the most number of attributes
- * pattern classWithMaxNumberOfAttributes(class : Class, number : java Integer) {
- * //Calculates the largest class number
- * //Note use # to determine which parameter should be used for aggregation
- * //in this case to calculate max
- * number == max find classNumberOfAttributes(_, #tempNumber);
- * //Queries the class with the highest number
- * find classNumberOfAttributes(class, number);
- * }
- *
- *
- * @see Match
- * @see ClassWithMaxNumberOfAttributes
- *
- */
- 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 ClassWithMaxNumberOfAttributes.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 ClassWithMaxNumberOfAttributes.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_CLASS = 0;
-
- private final static int POSITION_NUMBER = 1;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ClassWithMaxNumberOfAttributes.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.
- * @param pNumber the fixed value of pattern parameter number, 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, final Integer pNumber) {
- return rawStreamAllMatches(new Object[]{pClass, pNumber}).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.
- * @param pNumber the fixed value of pattern parameter number, 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, final Integer pNumber) {
- return rawStreamAllMatches(new Object[]{pClass, pNumber});
- }
-
- /**
- * 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.
- * @param pNumber the fixed value of pattern parameter number, 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, final Integer pNumber) {
- return rawGetOneArbitraryMatch(new Object[]{pClass, pNumber});
- }
-
- /**
- * 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.
- * @param pNumber the fixed value of pattern parameter number, 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, final Integer pNumber) {
- return rawHasMatch(new Object[]{pClass, pNumber});
- }
-
- /**
- * 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.
- * @param pNumber the fixed value of pattern parameter number, 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, final Integer pNumber) {
- return rawCountMatches(new Object[]{pClass, pNumber});
- }
-
- /**
- * 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 pNumber the fixed value of pattern parameter number, 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 Integer pNumber, final Consumer super ClassWithMaxNumberOfAttributes.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass, pNumber}, 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.
- * @param pNumber the fixed value of pattern parameter number, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public ClassWithMaxNumberOfAttributes.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass, final Integer pNumber) {
- return ClassWithMaxNumberOfAttributes.Match.newMatch(pClass, pNumber);
- }
-
- /**
- * 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());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final ClassWithMaxNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final Integer pNumber) {
- return rawStreamAllValuesOfclass(new Object[]{null, pNumber});
- }
-
- /**
- * 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(final ClassWithMaxNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray()).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 Set getAllValuesOfclass(final Integer pNumber) {
- return rawStreamAllValuesOfclass(new Object[]{null, pNumber}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfnumber(final Object[] parameters) {
- return rawStreamAllValues(POSITION_NUMBER, parameters).map(Integer.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfnumber() {
- return rawStreamAllValuesOfnumber(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfnumber() {
- return rawStreamAllValuesOfnumber(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- *
- * 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 streamAllValuesOfnumber(final ClassWithMaxNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfnumber(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- *
- * 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 streamAllValuesOfnumber(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllValuesOfnumber(new Object[]{pClass, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfnumber(final ClassWithMaxNumberOfAttributes.Match partialMatch) {
- return rawStreamAllValuesOfnumber(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for number.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfnumber(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return rawStreamAllValuesOfnumber(new Object[]{pClass, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected ClassWithMaxNumberOfAttributes.Match tupleToMatch(final Tuple t) {
- try {
- return ClassWithMaxNumberOfAttributes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_CLASS), (Integer) t.get(POSITION_NUMBER));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ClassWithMaxNumberOfAttributes.Match arrayToMatch(final Object[] match) {
- try {
- return ClassWithMaxNumberOfAttributes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS], (Integer) match[POSITION_NUMBER]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ClassWithMaxNumberOfAttributes.Match arrayToMatchMutable(final Object[] match) {
- try {
- return ClassWithMaxNumberOfAttributes.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS], (Integer) match[POSITION_NUMBER]);
- } 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 ClassWithMaxNumberOfAttributes.instance();
- }
- }
-
- private ClassWithMaxNumberOfAttributes() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ClassWithMaxNumberOfAttributes instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected ClassWithMaxNumberOfAttributes.Matcher instantiate(final ViatraQueryEngine engine) {
- return ClassWithMaxNumberOfAttributes.Matcher.on(engine);
- }
-
- @Override
- public ClassWithMaxNumberOfAttributes.Matcher instantiate() {
- return ClassWithMaxNumberOfAttributes.Matcher.create();
- }
-
- @Override
- public ClassWithMaxNumberOfAttributes.Match newEmptyMatch() {
- return ClassWithMaxNumberOfAttributes.Match.newEmptyMatch();
- }
-
- @Override
- public ClassWithMaxNumberOfAttributes.Match newMatch(final Object... parameters) {
- return ClassWithMaxNumberOfAttributes.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0], (java.lang.Integer) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassWithMaxNumberOfAttributes (visibility: PUBLIC, simpleName: ClassWithMaxNumberOfAttributes, identifier: com.incquerylabs.v4md.test.queries.ClassWithMaxNumberOfAttributes, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassWithMaxNumberOfAttributes (visibility: PUBLIC, simpleName: ClassWithMaxNumberOfAttributes, identifier: com.incquerylabs.v4md.test.queries.ClassWithMaxNumberOfAttributes, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static ClassWithMaxNumberOfAttributes INSTANCE = new ClassWithMaxNumberOfAttributes();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static ClassWithMaxNumberOfAttributes.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 PParameter parameter_number = new PParameter("number", "java.lang.Integer", new JavaTransitiveInstancesKey(java.lang.Integer.class), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class, parameter_number);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.classWithMaxNumberOfAttributes";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class","number");
- }
-
- @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_number = body.getOrCreateVariableByName("number");
- PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
- PVariable var__tempNumber = body.getOrCreateVariableByName("#tempNumber");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_number), new JavaTransitiveInstancesKey(java.lang.Integer.class));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class),
- new ExportedParameter(body, var_number, parameter_number)
- ));
- // //Calculates the largest class number //Note use # to determine which parameter should be used for aggregation //in this case to calculate max number == max find classNumberOfAttributes(_, #tempNumber)
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new AggregatorConstraint(new max().getAggregatorLogic(Integer.class), body, Tuples.flatTupleOf(var___0_, var__tempNumber), ClassNumberOfAttributes.instance().getInternalQueryRepresentation(), var__virtual_0_, 1);
- new Equality(body, var_number, var__virtual_0_);
- // //Queries the class with the highest number find classNumberOfAttributes(class, number)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_class, var_number), ClassNumberOfAttributes.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Classes.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Classes.java
deleted file mode 100644
index 586b31d..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Classes.java
+++ /dev/null
@@ -1,535 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Aggregator_Functions.vql
- */
-package com.incquerylabs.v4md.test.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:
- *
- * //Queries classes
- * 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.v4md.test.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) {
- if ("class".equals(parameterName)) return this.fClass;
- 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.v4md.test.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.v4md.test.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:
- *
- * //Queries classes
- * 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 final static int POSITION_CLASS = 0;
-
- private final static 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 JvmGenericType: com.incquerylabs.v4md.test.queries.Classes (visibility: PUBLIC, simpleName: Classes, identifier: com.incquerylabs.v4md.test.queries.Classes, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.Classes (visibility: PUBLIC, simpleName: Classes, identifier: com.incquerylabs.v4md.test.queries.Classes, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static 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.v4md.test.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.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassesWithEmptyName.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassesWithEmptyName.java
deleted file mode 100644
index 1a5945c..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassesWithEmptyName.java
+++ /dev/null
@@ -1,574 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Subpattern_Calls.vql
- */
-package com.incquerylabs.v4md.test.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.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:
- *
- * pattern classesWithEmptyName(class : Class){
- * //simple pattern constraint --{@literal >} maps classes to their names
- * Class.name(class, name);
- * //check expression --{@literal >} checks if the name is an empty string
- * check(name.equals(""));
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class ClassesWithEmptyName extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.classesWithEmptyName 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) {
- if ("class".equals(parameterName)) return this.fClass;
- 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.v4md.test.queries.classesWithEmptyName";
- }
-
- @Override
- public List parameterNames() {
- return ClassesWithEmptyName.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass};
- }
-
- @Override
- public ClassesWithEmptyName.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 ClassesWithEmptyName.Match)) {
- ClassesWithEmptyName.Match other = (ClassesWithEmptyName.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 ClassesWithEmptyName specification() {
- return ClassesWithEmptyName.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 ClassesWithEmptyName.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 ClassesWithEmptyName.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 ClassesWithEmptyName.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Immutable(pClass);
- }
-
- private static final class Mutable extends ClassesWithEmptyName.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 ClassesWithEmptyName.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.v4md.test.queries.classesWithEmptyName 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 classesWithEmptyName(class : Class){
- * //simple pattern constraint --{@literal >} maps classes to their names
- * Class.name(class, name);
- * //check expression --{@literal >} checks if the name is an empty string
- * check(name.equals(""));
- * }
- *
- *
- * @see Match
- * @see ClassesWithEmptyName
- *
- */
- 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 ClassesWithEmptyName.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 ClassesWithEmptyName.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_CLASS = 0;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ClassesWithEmptyName.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 ClassesWithEmptyName.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 ClassesWithEmptyName.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return ClassesWithEmptyName.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 ClassesWithEmptyName.Match tupleToMatch(final Tuple t) {
- try {
- return ClassesWithEmptyName.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 ClassesWithEmptyName.Match arrayToMatch(final Object[] match) {
- try {
- return ClassesWithEmptyName.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 ClassesWithEmptyName.Match arrayToMatchMutable(final Object[] match) {
- try {
- return ClassesWithEmptyName.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 ClassesWithEmptyName.instance();
- }
- }
-
- private ClassesWithEmptyName() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ClassesWithEmptyName instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected ClassesWithEmptyName.Matcher instantiate(final ViatraQueryEngine engine) {
- return ClassesWithEmptyName.Matcher.on(engine);
- }
-
- @Override
- public ClassesWithEmptyName.Matcher instantiate() {
- return ClassesWithEmptyName.Matcher.create();
- }
-
- @Override
- public ClassesWithEmptyName.Match newEmptyMatch() {
- return ClassesWithEmptyName.Match.newEmptyMatch();
- }
-
- @Override
- public ClassesWithEmptyName.Match newMatch(final Object... parameters) {
- return ClassesWithEmptyName.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassesWithEmptyName (visibility: PUBLIC, simpleName: ClassesWithEmptyName, identifier: com.incquerylabs.v4md.test.queries.ClassesWithEmptyName, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassesWithEmptyName (visibility: PUBLIC, simpleName: ClassesWithEmptyName, identifier: com.incquerylabs.v4md.test.queries.ClassesWithEmptyName, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static ClassesWithEmptyName INSTANCE = new ClassesWithEmptyName();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static ClassesWithEmptyName.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.v4md.test.queries.classesWithEmptyName";
- }
-
- @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", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class)
- ));
- // //simple pattern constraint --> maps classes to their names Class.name(class, name)
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- 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 expression --> checks if the name is an empty string check(name.equals(""))
- new ExpressionEvaluation(body, new IExpressionEvaluator() {
-
- @Override
- public String getShortDescription() {
- return "Expression evaluation from pattern classesWithEmptyName";
- }
-
- @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) {
- boolean _equals = name.equals("");
- return _equals;
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassesWithNameThatContainsID.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassesWithNameThatContainsID.java
deleted file mode 100644
index 1e5e00e..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassesWithNameThatContainsID.java
+++ /dev/null
@@ -1,574 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Check_Expression.vql
- */
-package com.incquerylabs.v4md.test.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.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:
- *
- * pattern classesWithNameThatContainsID(class : Class){
- * Class.name(class, name);
- * //Check expression that checks if the class' name contains the substring 'id'
- * //Inside a check expression standard java code can be used (in this case String.equals)
- * check(name.contains("id"));
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class ClassesWithNameThatContainsID extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.classesWithNameThatContainsID 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) {
- if ("class".equals(parameterName)) return this.fClass;
- 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.v4md.test.queries.classesWithNameThatContainsID";
- }
-
- @Override
- public List parameterNames() {
- return ClassesWithNameThatContainsID.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass};
- }
-
- @Override
- public ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.Match)) {
- ClassesWithNameThatContainsID.Match other = (ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID specification() {
- return ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return new Immutable(pClass);
- }
-
- private static final class Mutable extends ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.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.v4md.test.queries.classesWithNameThatContainsID 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 classesWithNameThatContainsID(class : Class){
- * Class.name(class, name);
- * //Check expression that checks if the class' name contains the substring 'id'
- * //Inside a check expression standard java code can be used (in this case String.equals)
- * check(name.contains("id"));
- * }
- *
- *
- * @see Match
- * @see ClassesWithNameThatContainsID
- *
- */
- 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 ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_CLASS = 0;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass) {
- return ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.Match tupleToMatch(final Tuple t) {
- try {
- return ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.Match arrayToMatch(final Object[] match) {
- try {
- return ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.Match arrayToMatchMutable(final Object[] match) {
- try {
- return ClassesWithNameThatContainsID.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 ClassesWithNameThatContainsID.instance();
- }
- }
-
- private ClassesWithNameThatContainsID() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ClassesWithNameThatContainsID instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected ClassesWithNameThatContainsID.Matcher instantiate(final ViatraQueryEngine engine) {
- return ClassesWithNameThatContainsID.Matcher.on(engine);
- }
-
- @Override
- public ClassesWithNameThatContainsID.Matcher instantiate() {
- return ClassesWithNameThatContainsID.Matcher.create();
- }
-
- @Override
- public ClassesWithNameThatContainsID.Match newEmptyMatch() {
- return ClassesWithNameThatContainsID.Match.newEmptyMatch();
- }
-
- @Override
- public ClassesWithNameThatContainsID.Match newMatch(final Object... parameters) {
- return ClassesWithNameThatContainsID.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassesWithNameThatContainsID (visibility: PUBLIC, simpleName: ClassesWithNameThatContainsID, identifier: com.incquerylabs.v4md.test.queries.ClassesWithNameThatContainsID, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassesWithNameThatContainsID (visibility: PUBLIC, simpleName: ClassesWithNameThatContainsID, identifier: com.incquerylabs.v4md.test.queries.ClassesWithNameThatContainsID, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static ClassesWithNameThatContainsID INSTANCE = new ClassesWithNameThatContainsID();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static ClassesWithNameThatContainsID.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.v4md.test.queries.classesWithNameThatContainsID";
- }
-
- @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", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class)
- ));
- // Class.name(class, name)
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- 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 expression that checks if the class' name contains the substring 'id' //Inside a check expression standard java code can be used (in this case String.equals) check(name.contains("id"))
- new ExpressionEvaluation(body, new IExpressionEvaluator() {
-
- @Override
- public String getShortDescription() {
- return "Expression evaluation from pattern classesWithNameThatContainsID";
- }
-
- @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) {
- boolean _contains = name.contains("id");
- return _contains;
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassesWithSameNamedProperty.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassesWithSameNamedProperty.java
deleted file mode 100644
index 62811e8..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ClassesWithSameNamedProperty.java
+++ /dev/null
@@ -1,828 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Pattern_Constraints.vql
- */
-package com.incquerylabs.v4md.test.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.Inequality;
-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:
- *
- * //Classes that have attributes that have the same name
- * pattern classesWithSameNamedProperty(class1 : Class, class2 : Class, name : java String){
- * //using the 'name' parameter in both places will ensure that the name is the same
- * Class.ownedAttribute.name(class1, name);
- * Class.ownedAttribute.name(class2, name);
- * //Ensure that they are not the same class
- * class1 != class2;
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class ClassesWithSameNamedProperty extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.classesWithSameNamedProperty 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 fClass1;
-
- private com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class fClass2;
-
- private String fName;
-
- private static List parameterNames = makeImmutableList("class1", "class2", "name");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- this.fClass1 = pClass1;
- this.fClass2 = pClass2;
- this.fName = pName;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("class1".equals(parameterName)) return this.fClass1;
- if ("class2".equals(parameterName)) return this.fClass2;
- if ("name".equals(parameterName)) return this.fName;
- return null;
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getClass1() {
- return this.fClass1;
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getClass2() {
- return this.fClass2;
- }
-
- public String getName() {
- return this.fName;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("class1".equals(parameterName) ) {
- this.fClass1 = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- if ("class2".equals(parameterName) ) {
- this.fClass2 = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- if ("name".equals(parameterName) ) {
- this.fName = (String) newValue;
- return true;
- }
- return false;
- }
-
- public void setClass1(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass1) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass1 = pClass1;
- }
-
- public void setClass2(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass2 = pClass2;
- }
-
- public void setName(final String pName) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fName = pName;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.classesWithSameNamedProperty";
- }
-
- @Override
- public List parameterNames() {
- return ClassesWithSameNamedProperty.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass1, fClass2, fName};
- }
-
- @Override
- public ClassesWithSameNamedProperty.Match toImmutable() {
- return isMutable() ? newMatch(fClass1, fClass2, fName) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class1\"=" + prettyPrintValue(fClass1) + ", ");
- result.append("\"class2\"=" + prettyPrintValue(fClass2) + ", ");
- result.append("\"name\"=" + prettyPrintValue(fName));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass1, fClass2, fName);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof ClassesWithSameNamedProperty.Match)) {
- ClassesWithSameNamedProperty.Match other = (ClassesWithSameNamedProperty.Match) obj;
- return Objects.equals(fClass1, other.fClass1) && Objects.equals(fClass2, other.fClass2) && 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 ClassesWithSameNamedProperty specification() {
- return ClassesWithSameNamedProperty.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 ClassesWithSameNamedProperty.Match newEmptyMatch() {
- return new Mutable(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 pClass1 the fixed value of pattern parameter class1, or null if not bound.
- * @param pClass2 the fixed value of pattern parameter class2, 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 ClassesWithSameNamedProperty.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- return new Mutable(pClass1, pClass2, 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 pClass1 the fixed value of pattern parameter class1, or null if not bound.
- * @param pClass2 the fixed value of pattern parameter class2, 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 ClassesWithSameNamedProperty.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- return new Immutable(pClass1, pClass2, pName);
- }
-
- private static final class Mutable extends ClassesWithSameNamedProperty.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- super(pClass1, pClass2, pName);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends ClassesWithSameNamedProperty.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- super(pClass1, pClass2, pName);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.classesWithSameNamedProperty 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:
- *
- * //Classes that have attributes that have the same name
- * pattern classesWithSameNamedProperty(class1 : Class, class2 : Class, name : java String){
- * //using the 'name' parameter in both places will ensure that the name is the same
- * Class.ownedAttribute.name(class1, name);
- * Class.ownedAttribute.name(class2, name);
- * //Ensure that they are not the same class
- * class1 != class2;
- * }
- *
- *
- * @see Match
- * @see ClassesWithSameNamedProperty
- *
- */
- 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 ClassesWithSameNamedProperty.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 ClassesWithSameNamedProperty.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_CLASS1 = 0;
-
- private final static int POSITION_CLASS2 = 1;
-
- private final static int POSITION_NAME = 2;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ClassesWithSameNamedProperty.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 pClass1 the fixed value of pattern parameter class1, or null if not bound.
- * @param pClass2 the fixed value of pattern parameter class2, 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.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- return rawStreamAllMatches(new Object[]{pClass1, pClass2, 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 pClass1 the fixed value of pattern parameter class1, or null if not bound.
- * @param pClass2 the fixed value of pattern parameter class2, 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.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- return rawStreamAllMatches(new Object[]{pClass1, pClass2, 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 pClass1 the fixed value of pattern parameter class1, or null if not bound.
- * @param pClass2 the fixed value of pattern parameter class2, 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.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- return rawGetOneArbitraryMatch(new Object[]{pClass1, pClass2, 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 pClass1 the fixed value of pattern parameter class1, or null if not bound.
- * @param pClass2 the fixed value of pattern parameter class2, 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.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- return rawHasMatch(new Object[]{pClass1, pClass2, pName});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pClass1 the fixed value of pattern parameter class1, or null if not bound.
- * @param pClass2 the fixed value of pattern parameter class2, 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.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- return rawCountMatches(new Object[]{pClass1, pClass2, 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 pClass1 the fixed value of pattern parameter class1, or null if not bound.
- * @param pClass2 the fixed value of pattern parameter class2, 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.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName, final Consumer super ClassesWithSameNamedProperty.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass1, pClass2, 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 pClass1 the fixed value of pattern parameter class1, or null if not bound.
- * @param pClass2 the fixed value of pattern parameter class2, 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 ClassesWithSameNamedProperty.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- return ClassesWithSameNamedProperty.Match.newMatch(pClass1, pClass2, pName);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfclass1(final Object[] parameters) {
- return rawStreamAllValues(POSITION_CLASS1, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass1() {
- return rawStreamAllValuesOfclass1(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfclass1() {
- return rawStreamAllValuesOfclass1(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class1.
- *
- * 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 streamAllValuesOfclass1(final ClassesWithSameNamedProperty.Match partialMatch) {
- return rawStreamAllValuesOfclass1(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class1.
- *
- * 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 streamAllValuesOfclass1(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- return rawStreamAllValuesOfclass1(new Object[]{null, pClass2, pName});
- }
-
- /**
- * Retrieve the set of values that occur in matches for class1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass1(final ClassesWithSameNamedProperty.Match partialMatch) {
- return rawStreamAllValuesOfclass1(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass1(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2, final String pName) {
- return rawStreamAllValuesOfclass1(new Object[]{null, pClass2, pName}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfclass2(final Object[] parameters) {
- return rawStreamAllValues(POSITION_CLASS2, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for class2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass2() {
- return rawStreamAllValuesOfclass2(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfclass2() {
- return rawStreamAllValuesOfclass2(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class2.
- *
- * 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 streamAllValuesOfclass2(final ClassesWithSameNamedProperty.Match partialMatch) {
- return rawStreamAllValuesOfclass2(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class2.
- *
- * 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 streamAllValuesOfclass2(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass1, final String pName) {
- return rawStreamAllValuesOfclass2(new Object[]{pClass1, null, pName});
- }
-
- /**
- * Retrieve the set of values that occur in matches for class2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass2(final ClassesWithSameNamedProperty.Match partialMatch) {
- return rawStreamAllValuesOfclass2(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfclass2(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass1, final String pName) {
- return rawStreamAllValuesOfclass2(new Object[]{pClass1, 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 ClassesWithSameNamedProperty.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.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2) {
- return rawStreamAllValuesOfname(new Object[]{pClass1, pClass2, 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 ClassesWithSameNamedProperty.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.Class pClass1, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pClass2) {
- return rawStreamAllValuesOfname(new Object[]{pClass1, pClass2, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected ClassesWithSameNamedProperty.Match tupleToMatch(final Tuple t) {
- try {
- return ClassesWithSameNamedProperty.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_CLASS1), (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_CLASS2), (String) t.get(POSITION_NAME));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ClassesWithSameNamedProperty.Match arrayToMatch(final Object[] match) {
- try {
- return ClassesWithSameNamedProperty.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS1], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS2], (String) match[POSITION_NAME]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ClassesWithSameNamedProperty.Match arrayToMatchMutable(final Object[] match) {
- try {
- return ClassesWithSameNamedProperty.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS1], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_CLASS2], (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 ClassesWithSameNamedProperty.instance();
- }
- }
-
- private ClassesWithSameNamedProperty() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ClassesWithSameNamedProperty instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected ClassesWithSameNamedProperty.Matcher instantiate(final ViatraQueryEngine engine) {
- return ClassesWithSameNamedProperty.Matcher.on(engine);
- }
-
- @Override
- public ClassesWithSameNamedProperty.Matcher instantiate() {
- return ClassesWithSameNamedProperty.Matcher.create();
- }
-
- @Override
- public ClassesWithSameNamedProperty.Match newEmptyMatch() {
- return ClassesWithSameNamedProperty.Match.newEmptyMatch();
- }
-
- @Override
- public ClassesWithSameNamedProperty.Match newMatch(final Object... parameters) {
- return ClassesWithSameNamedProperty.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[1], (java.lang.String) parameters[2]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassesWithSameNamedProperty (visibility: PUBLIC, simpleName: ClassesWithSameNamedProperty, identifier: com.incquerylabs.v4md.test.queries.ClassesWithSameNamedProperty, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ClassesWithSameNamedProperty (visibility: PUBLIC, simpleName: ClassesWithSameNamedProperty, identifier: com.incquerylabs.v4md.test.queries.ClassesWithSameNamedProperty, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static ClassesWithSameNamedProperty INSTANCE = new ClassesWithSameNamedProperty();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static ClassesWithSameNamedProperty.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_class1 = new PParameter("class1", "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 PParameter parameter_class2 = new PParameter("class2", "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 PParameter parameter_name = new PParameter("name", "java.lang.String", new JavaTransitiveInstancesKey(java.lang.String.class), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class1, parameter_class2, parameter_name);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.classesWithSameNamedProperty";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class1","class2","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_class1 = body.getOrCreateVariableByName("class1");
- PVariable var_class2 = body.getOrCreateVariableByName("class2");
- PVariable var_name = body.getOrCreateVariableByName("name");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_class2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- new TypeFilterConstraint(body, Tuples.flatTupleOf(var_name), new JavaTransitiveInstancesKey(java.lang.String.class));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class1, parameter_class1),
- new ExportedParameter(body, var_class2, parameter_class2),
- new ExportedParameter(body, var_name, parameter_name)
- ));
- // //using the 'name' parameter in both places will ensure that the name is the same Class.ownedAttribute.name(class1, name)
- new TypeConstraint(body, Tuples.flatTupleOf(var_class1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class1, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "StructuredClassifier", "ownedAttribute")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Property")));
- 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", "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_name);
- // Class.ownedAttribute.name(class2, name)
- new TypeConstraint(body, Tuples.flatTupleOf(var_class2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class2, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "StructuredClassifier", "ownedAttribute")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Property")));
- 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_name);
- // //Ensure that they are not the same class class1 != class2
- new Inequality(body, var_class1, var_class2);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/DependencyChain.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/DependencyChain.java
deleted file mode 100644
index 039c1c7..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/DependencyChain.java
+++ /dev/null
@@ -1,706 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Circular_Dependency.vql
- */
-package com.incquerylabs.v4md.test.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 DependencyChain(source : Dependency, target : Dependency) {
- * Dependency.supplier(source, elem);
- * Dependency.client(target, elem);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class DependencyChain extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.DependencyChain 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) {
- if ("source".equals(parameterName)) return this.fSource;
- if ("target".equals(parameterName)) return this.fTarget;
- 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.v4md.test.queries.DependencyChain";
- }
-
- @Override
- public List parameterNames() {
- return DependencyChain.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fSource, fTarget};
- }
-
- @Override
- public DependencyChain.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 DependencyChain.Match)) {
- DependencyChain.Match other = (DependencyChain.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 DependencyChain specification() {
- return DependencyChain.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 DependencyChain.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 DependencyChain.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 DependencyChain.Match newMatch(final Dependency pSource, final Dependency pTarget) {
- return new Immutable(pSource, pTarget);
- }
-
- private static final class Mutable extends DependencyChain.Match {
- Mutable(final Dependency pSource, final Dependency pTarget) {
- super(pSource, pTarget);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends DependencyChain.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.v4md.test.queries.DependencyChain 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 DependencyChain(source : Dependency, target : Dependency) {
- * Dependency.supplier(source, elem);
- * Dependency.client(target, elem);
- * }
- *
- *
- * @see Match
- * @see DependencyChain
- *
- */
- 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 DependencyChain.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 DependencyChain.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_SOURCE = 0;
-
- private final static int POSITION_TARGET = 1;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(DependencyChain.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 DependencyChain.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 DependencyChain.Match newMatch(final Dependency pSource, final Dependency pTarget) {
- return DependencyChain.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 DependencyChain.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 DependencyChain.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 DependencyChain.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 DependencyChain.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 DependencyChain.Match tupleToMatch(final Tuple t) {
- try {
- return DependencyChain.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 DependencyChain.Match arrayToMatch(final Object[] match) {
- try {
- return DependencyChain.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 DependencyChain.Match arrayToMatchMutable(final Object[] match) {
- try {
- return DependencyChain.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 DependencyChain.instance();
- }
- }
-
- private DependencyChain() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static DependencyChain instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected DependencyChain.Matcher instantiate(final ViatraQueryEngine engine) {
- return DependencyChain.Matcher.on(engine);
- }
-
- @Override
- public DependencyChain.Matcher instantiate() {
- return DependencyChain.Matcher.create();
- }
-
- @Override
- public DependencyChain.Match newEmptyMatch() {
- return DependencyChain.Match.newEmptyMatch();
- }
-
- @Override
- public DependencyChain.Match newMatch(final Object... parameters) {
- return DependencyChain.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 JvmGenericType: com.incquerylabs.v4md.test.queries.DependencyChain (visibility: PUBLIC, simpleName: DependencyChain, identifier: com.incquerylabs.v4md.test.queries.DependencyChain, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.DependencyChain (visibility: PUBLIC, simpleName: DependencyChain, identifier: com.incquerylabs.v4md.test.queries.DependencyChain, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static DependencyChain INSTANCE = new DependencyChain();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static DependencyChain.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.v4md.test.queries.DependencyChain";
- }
-
- @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.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/GetSuperClass.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/GetSuperClass.java
deleted file mode 100644
index 295a578..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/GetSuperClass.java
+++ /dev/null
@@ -1,708 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Transitive_Closure.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier;
-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:
- *
- * Get superclasses of a class
- * maps a class to its superclass --{@literal >} the main pattern uses this subpattern to produce a class generalization hierarchy
- *
- * pattern getSuperClass(class : Classifier, superClass: Classifier) {
- * Generalization.general(gen, superClass);
- * Generalization.specific(gen, class);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class GetSuperClass extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.getSuperClass 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 Classifier fClass;
-
- private Classifier fSuperClass;
-
- private static List parameterNames = makeImmutableList("class", "superClass");
-
- private Match(final Classifier pClass, final Classifier pSuperClass) {
- this.fClass = pClass;
- this.fSuperClass = pSuperClass;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("class".equals(parameterName)) return this.fClass;
- if ("superClass".equals(parameterName)) return this.fSuperClass;
- return null;
- }
-
- public Classifier getValueOfClass() {
- return this.fClass;
- }
-
- public Classifier getSuperClass() {
- return this.fSuperClass;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("class".equals(parameterName) ) {
- this.fClass = (Classifier) newValue;
- return true;
- }
- if ("superClass".equals(parameterName) ) {
- this.fSuperClass = (Classifier) newValue;
- return true;
- }
- return false;
- }
-
- public void setClass(final Classifier pClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass = pClass;
- }
-
- public void setSuperClass(final Classifier pSuperClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fSuperClass = pSuperClass;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.getSuperClass";
- }
-
- @Override
- public List parameterNames() {
- return GetSuperClass.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass, fSuperClass};
- }
-
- @Override
- public GetSuperClass.Match toImmutable() {
- return isMutable() ? newMatch(fClass, fSuperClass) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass) + ", ");
- result.append("\"superClass\"=" + prettyPrintValue(fSuperClass));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass, fSuperClass);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof GetSuperClass.Match)) {
- GetSuperClass.Match other = (GetSuperClass.Match) obj;
- return Objects.equals(fClass, other.fClass) && Objects.equals(fSuperClass, other.fSuperClass);
- } 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 GetSuperClass specification() {
- return GetSuperClass.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 GetSuperClass.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 pClass the fixed value of pattern parameter class, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static GetSuperClass.Match newMutableMatch(final Classifier pClass, final Classifier pSuperClass) {
- return new Mutable(pClass, pSuperClass);
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static GetSuperClass.Match newMatch(final Classifier pClass, final Classifier pSuperClass) {
- return new Immutable(pClass, pSuperClass);
- }
-
- private static final class Mutable extends GetSuperClass.Match {
- Mutable(final Classifier pClass, final Classifier pSuperClass) {
- super(pClass, pSuperClass);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends GetSuperClass.Match {
- Immutable(final Classifier pClass, final Classifier pSuperClass) {
- super(pClass, pSuperClass);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.getSuperClass 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:
- *
- * Get superclasses of a class
- * maps a class to its superclass --{@literal >} the main pattern uses this subpattern to produce a class generalization hierarchy
- *
- * pattern getSuperClass(class : Classifier, superClass: Classifier) {
- * Generalization.general(gen, superClass);
- * Generalization.specific(gen, class);
- * }
- *
- *
- * @see Match
- * @see GetSuperClass
- *
- */
- 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 GetSuperClass.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 GetSuperClass.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_CLASS = 0;
-
- private final static int POSITION_SUPERCLASS = 1;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(GetSuperClass.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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final Classifier pClass, final Classifier pSuperClass) {
- return rawStreamAllMatches(new Object[]{pClass, pSuperClass}).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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final Classifier pClass, final Classifier pSuperClass) {
- return rawStreamAllMatches(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final Classifier pClass, final Classifier pSuperClass) {
- return rawGetOneArbitraryMatch(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final Classifier pClass, final Classifier pSuperClass) {
- return rawHasMatch(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final Classifier pClass, final Classifier pSuperClass) {
- return rawCountMatches(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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 pSuperClass the fixed value of pattern parameter superClass, 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 Classifier pClass, final Classifier pSuperClass, final Consumer super GetSuperClass.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass, pSuperClass}, 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public GetSuperClass.Match newMatch(final Classifier pClass, final Classifier pSuperClass) {
- return GetSuperClass.Match.newMatch(pClass, pSuperClass);
- }
-
- /**
- * 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(Classifier.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());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final GetSuperClass.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final Classifier pSuperClass) {
- return rawStreamAllValuesOfclass(new Object[]{null, pSuperClass});
- }
-
- /**
- * 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(final GetSuperClass.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray()).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 Set getAllValuesOfclass(final Classifier pSuperClass) {
- return rawStreamAllValuesOfclass(new Object[]{null, pSuperClass}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfsuperClass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_SUPERCLASS, parameters).map(Classifier.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass() {
- return rawStreamAllValuesOfsuperClass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsuperClass() {
- return rawStreamAllValuesOfsuperClass(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- *
- * 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 streamAllValuesOfsuperClass(final GetSuperClass.Match partialMatch) {
- return rawStreamAllValuesOfsuperClass(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- *
- * 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 streamAllValuesOfsuperClass(final Classifier pClass) {
- return rawStreamAllValuesOfsuperClass(new Object[]{pClass, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass(final GetSuperClass.Match partialMatch) {
- return rawStreamAllValuesOfsuperClass(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass(final Classifier pClass) {
- return rawStreamAllValuesOfsuperClass(new Object[]{pClass, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected GetSuperClass.Match tupleToMatch(final Tuple t) {
- try {
- return GetSuperClass.Match.newMatch((Classifier) t.get(POSITION_CLASS), (Classifier) t.get(POSITION_SUPERCLASS));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected GetSuperClass.Match arrayToMatch(final Object[] match) {
- try {
- return GetSuperClass.Match.newMatch((Classifier) match[POSITION_CLASS], (Classifier) match[POSITION_SUPERCLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected GetSuperClass.Match arrayToMatchMutable(final Object[] match) {
- try {
- return GetSuperClass.Match.newMutableMatch((Classifier) match[POSITION_CLASS], (Classifier) match[POSITION_SUPERCLASS]);
- } 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 GetSuperClass.instance();
- }
- }
-
- private GetSuperClass() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static GetSuperClass instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected GetSuperClass.Matcher instantiate(final ViatraQueryEngine engine) {
- return GetSuperClass.Matcher.on(engine);
- }
-
- @Override
- public GetSuperClass.Matcher instantiate() {
- return GetSuperClass.Matcher.create();
- }
-
- @Override
- public GetSuperClass.Match newEmptyMatch() {
- return GetSuperClass.Match.newEmptyMatch();
- }
-
- @Override
- public GetSuperClass.Match newMatch(final Object... parameters) {
- return GetSuperClass.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.GetSuperClass (visibility: PUBLIC, simpleName: GetSuperClass, identifier: com.incquerylabs.v4md.test.queries.GetSuperClass, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.GetSuperClass (visibility: PUBLIC, simpleName: GetSuperClass, identifier: com.incquerylabs.v4md.test.queries.GetSuperClass, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static GetSuperClass INSTANCE = new GetSuperClass();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static GetSuperClass.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_class = new PParameter("class", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")), PParameterDirection.INOUT);
-
- private final PParameter parameter_superClass = new PParameter("superClass", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class, parameter_superClass);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.getSuperClass";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class","superClass");
- }
-
- @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_superClass = body.getOrCreateVariableByName("superClass");
- PVariable var_gen = body.getOrCreateVariableByName("gen");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_superClass), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class),
- new ExportedParameter(body, var_superClass, parameter_superClass)
- ));
- // Generalization.general(gen, superClass)
- new TypeConstraint(body, Tuples.flatTupleOf(var_gen), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Generalization")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_gen, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Generalization", "general")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- new Equality(body, var__virtual_0_, var_superClass);
- // Generalization.specific(gen, class)
- new TypeConstraint(body, Tuples.flatTupleOf(var_gen), 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_gen, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Generalization", "specific")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- new Equality(body, var__virtual_1_, var_class);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/GetSuperClassOrSelf.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/GetSuperClassOrSelf.java
deleted file mode 100644
index 794c52b..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/GetSuperClassOrSelf.java
+++ /dev/null
@@ -1,730 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Transitive_Closure.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.GetSuperClass;
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier;
-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.Equality;
-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:
- *
- * Produce Class inheritance hierarchy
- * 'or' keyword represents an or relation between bodies --{@literal >} one of them needs to apply to the parameters for them to produce a match
- * note that the transitive closure does not appear as parameters of a single match, but a number of matches in a following way:
- * class1 --{@literal >} parent1
- * class1 --{@literal >} parent2
- * ...
- *
- * pattern getSuperClassOrSelf(class : Classifier, superClass: Classifier) {
- * // semantics for transitive closure can be implemented this way
- * // by default the transitive closure does not add the trivial relation to the TC
- * class == superClass;
- * } or {
- * //transitive closure
- * find getSuperClass+(class, superClass);
- *
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class GetSuperClassOrSelf extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.getSuperClassOrSelf 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 Classifier fClass;
-
- private Classifier fSuperClass;
-
- private static List parameterNames = makeImmutableList("class", "superClass");
-
- private Match(final Classifier pClass, final Classifier pSuperClass) {
- this.fClass = pClass;
- this.fSuperClass = pSuperClass;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("class".equals(parameterName)) return this.fClass;
- if ("superClass".equals(parameterName)) return this.fSuperClass;
- return null;
- }
-
- public Classifier getValueOfClass() {
- return this.fClass;
- }
-
- public Classifier getSuperClass() {
- return this.fSuperClass;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("class".equals(parameterName) ) {
- this.fClass = (Classifier) newValue;
- return true;
- }
- if ("superClass".equals(parameterName) ) {
- this.fSuperClass = (Classifier) newValue;
- return true;
- }
- return false;
- }
-
- public void setClass(final Classifier pClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass = pClass;
- }
-
- public void setSuperClass(final Classifier pSuperClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fSuperClass = pSuperClass;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.getSuperClassOrSelf";
- }
-
- @Override
- public List parameterNames() {
- return GetSuperClassOrSelf.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass, fSuperClass};
- }
-
- @Override
- public GetSuperClassOrSelf.Match toImmutable() {
- return isMutable() ? newMatch(fClass, fSuperClass) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass) + ", ");
- result.append("\"superClass\"=" + prettyPrintValue(fSuperClass));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass, fSuperClass);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof GetSuperClassOrSelf.Match)) {
- GetSuperClassOrSelf.Match other = (GetSuperClassOrSelf.Match) obj;
- return Objects.equals(fClass, other.fClass) && Objects.equals(fSuperClass, other.fSuperClass);
- } 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 GetSuperClassOrSelf specification() {
- return GetSuperClassOrSelf.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 GetSuperClassOrSelf.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 pClass the fixed value of pattern parameter class, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static GetSuperClassOrSelf.Match newMutableMatch(final Classifier pClass, final Classifier pSuperClass) {
- return new Mutable(pClass, pSuperClass);
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static GetSuperClassOrSelf.Match newMatch(final Classifier pClass, final Classifier pSuperClass) {
- return new Immutable(pClass, pSuperClass);
- }
-
- private static final class Mutable extends GetSuperClassOrSelf.Match {
- Mutable(final Classifier pClass, final Classifier pSuperClass) {
- super(pClass, pSuperClass);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends GetSuperClassOrSelf.Match {
- Immutable(final Classifier pClass, final Classifier pSuperClass) {
- super(pClass, pSuperClass);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.getSuperClassOrSelf 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:
- *
- * Produce Class inheritance hierarchy
- * 'or' keyword represents an or relation between bodies --{@literal >} one of them needs to apply to the parameters for them to produce a match
- * note that the transitive closure does not appear as parameters of a single match, but a number of matches in a following way:
- * class1 --{@literal >} parent1
- * class1 --{@literal >} parent2
- * ...
- *
- * pattern getSuperClassOrSelf(class : Classifier, superClass: Classifier) {
- * // semantics for transitive closure can be implemented this way
- * // by default the transitive closure does not add the trivial relation to the TC
- * class == superClass;
- * } or {
- * //transitive closure
- * find getSuperClass+(class, superClass);
- *
- * }
- *
- *
- * @see Match
- * @see GetSuperClassOrSelf
- *
- */
- 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 GetSuperClassOrSelf.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 GetSuperClassOrSelf.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_CLASS = 0;
-
- private final static int POSITION_SUPERCLASS = 1;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(GetSuperClassOrSelf.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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final Classifier pClass, final Classifier pSuperClass) {
- return rawStreamAllMatches(new Object[]{pClass, pSuperClass}).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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final Classifier pClass, final Classifier pSuperClass) {
- return rawStreamAllMatches(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final Classifier pClass, final Classifier pSuperClass) {
- return rawGetOneArbitraryMatch(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final Classifier pClass, final Classifier pSuperClass) {
- return rawHasMatch(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final Classifier pClass, final Classifier pSuperClass) {
- return rawCountMatches(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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 pSuperClass the fixed value of pattern parameter superClass, 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 Classifier pClass, final Classifier pSuperClass, final Consumer super GetSuperClassOrSelf.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass, pSuperClass}, 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public GetSuperClassOrSelf.Match newMatch(final Classifier pClass, final Classifier pSuperClass) {
- return GetSuperClassOrSelf.Match.newMatch(pClass, pSuperClass);
- }
-
- /**
- * 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(Classifier.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());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final GetSuperClassOrSelf.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final Classifier pSuperClass) {
- return rawStreamAllValuesOfclass(new Object[]{null, pSuperClass});
- }
-
- /**
- * 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(final GetSuperClassOrSelf.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray()).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 Set getAllValuesOfclass(final Classifier pSuperClass) {
- return rawStreamAllValuesOfclass(new Object[]{null, pSuperClass}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfsuperClass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_SUPERCLASS, parameters).map(Classifier.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass() {
- return rawStreamAllValuesOfsuperClass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsuperClass() {
- return rawStreamAllValuesOfsuperClass(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- *
- * 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 streamAllValuesOfsuperClass(final GetSuperClassOrSelf.Match partialMatch) {
- return rawStreamAllValuesOfsuperClass(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- *
- * 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 streamAllValuesOfsuperClass(final Classifier pClass) {
- return rawStreamAllValuesOfsuperClass(new Object[]{pClass, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass(final GetSuperClassOrSelf.Match partialMatch) {
- return rawStreamAllValuesOfsuperClass(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass(final Classifier pClass) {
- return rawStreamAllValuesOfsuperClass(new Object[]{pClass, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected GetSuperClassOrSelf.Match tupleToMatch(final Tuple t) {
- try {
- return GetSuperClassOrSelf.Match.newMatch((Classifier) t.get(POSITION_CLASS), (Classifier) t.get(POSITION_SUPERCLASS));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected GetSuperClassOrSelf.Match arrayToMatch(final Object[] match) {
- try {
- return GetSuperClassOrSelf.Match.newMatch((Classifier) match[POSITION_CLASS], (Classifier) match[POSITION_SUPERCLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected GetSuperClassOrSelf.Match arrayToMatchMutable(final Object[] match) {
- try {
- return GetSuperClassOrSelf.Match.newMutableMatch((Classifier) match[POSITION_CLASS], (Classifier) match[POSITION_SUPERCLASS]);
- } 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 GetSuperClassOrSelf.instance();
- }
- }
-
- private GetSuperClassOrSelf() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static GetSuperClassOrSelf instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected GetSuperClassOrSelf.Matcher instantiate(final ViatraQueryEngine engine) {
- return GetSuperClassOrSelf.Matcher.on(engine);
- }
-
- @Override
- public GetSuperClassOrSelf.Matcher instantiate() {
- return GetSuperClassOrSelf.Matcher.create();
- }
-
- @Override
- public GetSuperClassOrSelf.Match newEmptyMatch() {
- return GetSuperClassOrSelf.Match.newEmptyMatch();
- }
-
- @Override
- public GetSuperClassOrSelf.Match newMatch(final Object... parameters) {
- return GetSuperClassOrSelf.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.GetSuperClassOrSelf (visibility: PUBLIC, simpleName: GetSuperClassOrSelf, identifier: com.incquerylabs.v4md.test.queries.GetSuperClassOrSelf, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.GetSuperClassOrSelf (visibility: PUBLIC, simpleName: GetSuperClassOrSelf, identifier: com.incquerylabs.v4md.test.queries.GetSuperClassOrSelf, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static GetSuperClassOrSelf INSTANCE = new GetSuperClassOrSelf();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static GetSuperClassOrSelf.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_class = new PParameter("class", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")), PParameterDirection.INOUT);
-
- private final PParameter parameter_superClass = new PParameter("superClass", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class, parameter_superClass);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.getSuperClassOrSelf";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class","superClass");
- }
-
- @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_superClass = body.getOrCreateVariableByName("superClass");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_superClass), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class),
- new ExportedParameter(body, var_superClass, parameter_superClass)
- ));
- // // * semantics for transitive closure can be implemented this way // by default the transitive closure does not add the trivial relation to the TC class == superClass
- new Equality(body, var_class, var_superClass);
- bodies.add(body);
- }
- {
- PBody body = new PBody(this);
- PVariable var_class = body.getOrCreateVariableByName("class");
- PVariable var_superClass = body.getOrCreateVariableByName("superClass");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_superClass), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class),
- new ExportedParameter(body, var_superClass, parameter_superClass)
- ));
- // //transitive closure find getSuperClass+(class, superClass)
- new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_class, var_superClass), GetSuperClass.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/GetSuperClasses.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/GetSuperClasses.java
deleted file mode 100644
index d814090..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/GetSuperClasses.java
+++ /dev/null
@@ -1,689 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Block_With_More_than_1_Parent.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.GetSuperClass;
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier;
-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 getSuperClasses(class : Classifier, superClass: Classifier){
- * find getSuperClass+(class, superClass);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class GetSuperClasses extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.getSuperClasses 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 Classifier fClass;
-
- private Classifier fSuperClass;
-
- private static List parameterNames = makeImmutableList("class", "superClass");
-
- private Match(final Classifier pClass, final Classifier pSuperClass) {
- this.fClass = pClass;
- this.fSuperClass = pSuperClass;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("class".equals(parameterName)) return this.fClass;
- if ("superClass".equals(parameterName)) return this.fSuperClass;
- return null;
- }
-
- public Classifier getValueOfClass() {
- return this.fClass;
- }
-
- public Classifier getSuperClass() {
- return this.fSuperClass;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("class".equals(parameterName) ) {
- this.fClass = (Classifier) newValue;
- return true;
- }
- if ("superClass".equals(parameterName) ) {
- this.fSuperClass = (Classifier) newValue;
- return true;
- }
- return false;
- }
-
- public void setClass(final Classifier pClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fClass = pClass;
- }
-
- public void setSuperClass(final Classifier pSuperClass) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fSuperClass = pSuperClass;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.getSuperClasses";
- }
-
- @Override
- public List parameterNames() {
- return GetSuperClasses.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fClass, fSuperClass};
- }
-
- @Override
- public GetSuperClasses.Match toImmutable() {
- return isMutable() ? newMatch(fClass, fSuperClass) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"class\"=" + prettyPrintValue(fClass) + ", ");
- result.append("\"superClass\"=" + prettyPrintValue(fSuperClass));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fClass, fSuperClass);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof GetSuperClasses.Match)) {
- GetSuperClasses.Match other = (GetSuperClasses.Match) obj;
- return Objects.equals(fClass, other.fClass) && Objects.equals(fSuperClass, other.fSuperClass);
- } 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 GetSuperClasses specification() {
- return GetSuperClasses.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 GetSuperClasses.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 pClass the fixed value of pattern parameter class, or null if not bound.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static GetSuperClasses.Match newMutableMatch(final Classifier pClass, final Classifier pSuperClass) {
- return new Mutable(pClass, pSuperClass);
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static GetSuperClasses.Match newMatch(final Classifier pClass, final Classifier pSuperClass) {
- return new Immutable(pClass, pSuperClass);
- }
-
- private static final class Mutable extends GetSuperClasses.Match {
- Mutable(final Classifier pClass, final Classifier pSuperClass) {
- super(pClass, pSuperClass);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends GetSuperClasses.Match {
- Immutable(final Classifier pClass, final Classifier pSuperClass) {
- super(pClass, pSuperClass);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.getSuperClasses 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 getSuperClasses(class : Classifier, superClass: Classifier){
- * find getSuperClass+(class, superClass);
- * }
- *
- *
- * @see Match
- * @see GetSuperClasses
- *
- */
- 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 GetSuperClasses.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 GetSuperClasses.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_CLASS = 0;
-
- private final static int POSITION_SUPERCLASS = 1;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(GetSuperClasses.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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final Classifier pClass, final Classifier pSuperClass) {
- return rawStreamAllMatches(new Object[]{pClass, pSuperClass}).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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final Classifier pClass, final Classifier pSuperClass) {
- return rawStreamAllMatches(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final Classifier pClass, final Classifier pSuperClass) {
- return rawGetOneArbitraryMatch(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final Classifier pClass, final Classifier pSuperClass) {
- return rawHasMatch(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final Classifier pClass, final Classifier pSuperClass) {
- return rawCountMatches(new Object[]{pClass, pSuperClass});
- }
-
- /**
- * 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 pSuperClass the fixed value of pattern parameter superClass, 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 Classifier pClass, final Classifier pSuperClass, final Consumer super GetSuperClasses.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pClass, pSuperClass}, 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.
- * @param pSuperClass the fixed value of pattern parameter superClass, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public GetSuperClasses.Match newMatch(final Classifier pClass, final Classifier pSuperClass) {
- return GetSuperClasses.Match.newMatch(pClass, pSuperClass);
- }
-
- /**
- * 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(Classifier.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());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final GetSuperClasses.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for class.
- *
- * 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 streamAllValuesOfclass(final Classifier pSuperClass) {
- return rawStreamAllValuesOfclass(new Object[]{null, pSuperClass});
- }
-
- /**
- * 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(final GetSuperClasses.Match partialMatch) {
- return rawStreamAllValuesOfclass(partialMatch.toArray()).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 Set getAllValuesOfclass(final Classifier pSuperClass) {
- return rawStreamAllValuesOfclass(new Object[]{null, pSuperClass}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfsuperClass(final Object[] parameters) {
- return rawStreamAllValues(POSITION_SUPERCLASS, parameters).map(Classifier.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass() {
- return rawStreamAllValuesOfsuperClass(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfsuperClass() {
- return rawStreamAllValuesOfsuperClass(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- *
- * 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 streamAllValuesOfsuperClass(final GetSuperClasses.Match partialMatch) {
- return rawStreamAllValuesOfsuperClass(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- *
- * 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 streamAllValuesOfsuperClass(final Classifier pClass) {
- return rawStreamAllValuesOfsuperClass(new Object[]{pClass, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass(final GetSuperClasses.Match partialMatch) {
- return rawStreamAllValuesOfsuperClass(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for superClass.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfsuperClass(final Classifier pClass) {
- return rawStreamAllValuesOfsuperClass(new Object[]{pClass, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected GetSuperClasses.Match tupleToMatch(final Tuple t) {
- try {
- return GetSuperClasses.Match.newMatch((Classifier) t.get(POSITION_CLASS), (Classifier) t.get(POSITION_SUPERCLASS));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected GetSuperClasses.Match arrayToMatch(final Object[] match) {
- try {
- return GetSuperClasses.Match.newMatch((Classifier) match[POSITION_CLASS], (Classifier) match[POSITION_SUPERCLASS]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected GetSuperClasses.Match arrayToMatchMutable(final Object[] match) {
- try {
- return GetSuperClasses.Match.newMutableMatch((Classifier) match[POSITION_CLASS], (Classifier) match[POSITION_SUPERCLASS]);
- } 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 GetSuperClasses.instance();
- }
- }
-
- private GetSuperClasses() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static GetSuperClasses instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected GetSuperClasses.Matcher instantiate(final ViatraQueryEngine engine) {
- return GetSuperClasses.Matcher.on(engine);
- }
-
- @Override
- public GetSuperClasses.Matcher instantiate() {
- return GetSuperClasses.Matcher.create();
- }
-
- @Override
- public GetSuperClasses.Match newEmptyMatch() {
- return GetSuperClasses.Match.newEmptyMatch();
- }
-
- @Override
- public GetSuperClasses.Match newMatch(final Object... parameters) {
- return GetSuperClasses.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.GetSuperClasses (visibility: PUBLIC, simpleName: GetSuperClasses, identifier: com.incquerylabs.v4md.test.queries.GetSuperClasses, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.GetSuperClasses (visibility: PUBLIC, simpleName: GetSuperClasses, identifier: com.incquerylabs.v4md.test.queries.GetSuperClasses, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static GetSuperClasses INSTANCE = new GetSuperClasses();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static GetSuperClasses.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_class = new PParameter("class", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")), PParameterDirection.INOUT);
-
- private final PParameter parameter_superClass = new PParameter("superClass", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_class, parameter_superClass);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.getSuperClasses";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("class","superClass");
- }
-
- @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_superClass = body.getOrCreateVariableByName("superClass");
- new TypeConstraint(body, Tuples.flatTupleOf(var_class), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_superClass), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Classifier")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_class, parameter_class),
- new ExportedParameter(body, var_superClass, parameter_superClass)
- ));
- // find getSuperClass+(class, superClass)
- new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_class, var_superClass), GetSuperClass.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/IDStringPropertyEqualityError.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/IDStringPropertyEqualityError.java
deleted file mode 100644
index 2970031..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/IDStringPropertyEqualityError.java
+++ /dev/null
@@ -1,700 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Non_Unique_Names.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.PropertyStringValueEquals;
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement;
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property;
-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.Inequality;
-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 responsible for detecting duplicate ID Property tagged values
- *
- * pattern IDStringPropertyEqualityError(elem : NamedElement, property : Property){
- * find PropertyStringValueEquals(elem, otherElement, property);
- * elem != otherElement;
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class IDStringPropertyEqualityError extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.IDStringPropertyEqualityError 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 fElem;
-
- private Property fProperty;
-
- private static List parameterNames = makeImmutableList("elem", "property");
-
- private Match(final NamedElement pElem, final Property pProperty) {
- this.fElem = pElem;
- this.fProperty = pProperty;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("elem".equals(parameterName)) return this.fElem;
- if ("property".equals(parameterName)) return this.fProperty;
- return null;
- }
-
- public NamedElement getElem() {
- return this.fElem;
- }
-
- public Property getProperty() {
- return this.fProperty;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("elem".equals(parameterName) ) {
- this.fElem = (NamedElement) newValue;
- return true;
- }
- if ("property".equals(parameterName) ) {
- this.fProperty = (Property) newValue;
- return true;
- }
- return false;
- }
-
- public void setElem(final NamedElement pElem) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fElem = pElem;
- }
-
- public void setProperty(final Property pProperty) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fProperty = pProperty;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.IDStringPropertyEqualityError";
- }
-
- @Override
- public List parameterNames() {
- return IDStringPropertyEqualityError.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fElem, fProperty};
- }
-
- @Override
- public IDStringPropertyEqualityError.Match toImmutable() {
- return isMutable() ? newMatch(fElem, fProperty) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"elem\"=" + prettyPrintValue(fElem) + ", ");
- result.append("\"property\"=" + prettyPrintValue(fProperty));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fElem, fProperty);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof IDStringPropertyEqualityError.Match)) {
- IDStringPropertyEqualityError.Match other = (IDStringPropertyEqualityError.Match) obj;
- return Objects.equals(fElem, other.fElem) && Objects.equals(fProperty, other.fProperty);
- } 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 IDStringPropertyEqualityError specification() {
- return IDStringPropertyEqualityError.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 IDStringPropertyEqualityError.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 pElem the fixed value of pattern parameter elem, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static IDStringPropertyEqualityError.Match newMutableMatch(final NamedElement pElem, final Property pProperty) {
- return new Mutable(pElem, pProperty);
- }
-
- /**
- * 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 pElem the fixed value of pattern parameter elem, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static IDStringPropertyEqualityError.Match newMatch(final NamedElement pElem, final Property pProperty) {
- return new Immutable(pElem, pProperty);
- }
-
- private static final class Mutable extends IDStringPropertyEqualityError.Match {
- Mutable(final NamedElement pElem, final Property pProperty) {
- super(pElem, pProperty);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends IDStringPropertyEqualityError.Match {
- Immutable(final NamedElement pElem, final Property pProperty) {
- super(pElem, pProperty);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.IDStringPropertyEqualityError 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 duplicate ID Property tagged values
- *
- * pattern IDStringPropertyEqualityError(elem : NamedElement, property : Property){
- * find PropertyStringValueEquals(elem, otherElement, property);
- * elem != otherElement;
- * }
- *
- *
- * @see Match
- * @see IDStringPropertyEqualityError
- *
- */
- 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 IDStringPropertyEqualityError.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 IDStringPropertyEqualityError.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_ELEM = 0;
-
- private final static int POSITION_PROPERTY = 1;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(IDStringPropertyEqualityError.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 pElem the fixed value of pattern parameter elem, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final NamedElement pElem, final Property pProperty) {
- return rawStreamAllMatches(new Object[]{pElem, pProperty}).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 pElem the fixed value of pattern parameter elem, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final NamedElement pElem, final Property pProperty) {
- return rawStreamAllMatches(new Object[]{pElem, pProperty});
- }
-
- /**
- * 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 pElem the fixed value of pattern parameter elem, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, 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 pElem, final Property pProperty) {
- return rawGetOneArbitraryMatch(new Object[]{pElem, pProperty});
- }
-
- /**
- * 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 pElem the fixed value of pattern parameter elem, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final NamedElement pElem, final Property pProperty) {
- return rawHasMatch(new Object[]{pElem, pProperty});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pElem the fixed value of pattern parameter elem, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final NamedElement pElem, final Property pProperty) {
- return rawCountMatches(new Object[]{pElem, pProperty});
- }
-
- /**
- * 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 pElem the fixed value of pattern parameter elem, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, 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 pElem, final Property pProperty, final Consumer super IDStringPropertyEqualityError.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pElem, pProperty}, 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 pElem the fixed value of pattern parameter elem, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public IDStringPropertyEqualityError.Match newMatch(final NamedElement pElem, final Property pProperty) {
- return IDStringPropertyEqualityError.Match.newMatch(pElem, pProperty);
- }
-
- /**
- * Retrieve the set of values that occur in matches for elem.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfelem(final Object[] parameters) {
- return rawStreamAllValues(POSITION_ELEM, parameters).map(NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for elem.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelem() {
- return rawStreamAllValuesOfelem(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for elem.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfelem() {
- return rawStreamAllValuesOfelem(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for elem.
- *
- * 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 streamAllValuesOfelem(final IDStringPropertyEqualityError.Match partialMatch) {
- return rawStreamAllValuesOfelem(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for elem.
- *
- * 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 streamAllValuesOfelem(final Property pProperty) {
- return rawStreamAllValuesOfelem(new Object[]{null, pProperty});
- }
-
- /**
- * Retrieve the set of values that occur in matches for elem.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelem(final IDStringPropertyEqualityError.Match partialMatch) {
- return rawStreamAllValuesOfelem(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for elem.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelem(final Property pProperty) {
- return rawStreamAllValuesOfelem(new Object[]{null, pProperty}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfproperty(final Object[] parameters) {
- return rawStreamAllValues(POSITION_PROPERTY, parameters).map(Property.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfproperty() {
- return rawStreamAllValuesOfproperty(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfproperty() {
- return rawStreamAllValuesOfproperty(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- *
- * 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 streamAllValuesOfproperty(final IDStringPropertyEqualityError.Match partialMatch) {
- return rawStreamAllValuesOfproperty(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- *
- * 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 streamAllValuesOfproperty(final NamedElement pElem) {
- return rawStreamAllValuesOfproperty(new Object[]{pElem, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfproperty(final IDStringPropertyEqualityError.Match partialMatch) {
- return rawStreamAllValuesOfproperty(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfproperty(final NamedElement pElem) {
- return rawStreamAllValuesOfproperty(new Object[]{pElem, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected IDStringPropertyEqualityError.Match tupleToMatch(final Tuple t) {
- try {
- return IDStringPropertyEqualityError.Match.newMatch((NamedElement) t.get(POSITION_ELEM), (Property) t.get(POSITION_PROPERTY));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected IDStringPropertyEqualityError.Match arrayToMatch(final Object[] match) {
- try {
- return IDStringPropertyEqualityError.Match.newMatch((NamedElement) match[POSITION_ELEM], (Property) match[POSITION_PROPERTY]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected IDStringPropertyEqualityError.Match arrayToMatchMutable(final Object[] match) {
- try {
- return IDStringPropertyEqualityError.Match.newMutableMatch((NamedElement) match[POSITION_ELEM], (Property) match[POSITION_PROPERTY]);
- } 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 IDStringPropertyEqualityError.instance();
- }
- }
-
- private IDStringPropertyEqualityError() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static IDStringPropertyEqualityError instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected IDStringPropertyEqualityError.Matcher instantiate(final ViatraQueryEngine engine) {
- return IDStringPropertyEqualityError.Matcher.on(engine);
- }
-
- @Override
- public IDStringPropertyEqualityError.Matcher instantiate() {
- return IDStringPropertyEqualityError.Matcher.create();
- }
-
- @Override
- public IDStringPropertyEqualityError.Match newEmptyMatch() {
- return IDStringPropertyEqualityError.Match.newEmptyMatch();
- }
-
- @Override
- public IDStringPropertyEqualityError.Match newMatch(final Object... parameters) {
- return IDStringPropertyEqualityError.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.IDStringPropertyEqualityError (visibility: PUBLIC, simpleName: IDStringPropertyEqualityError, identifier: com.incquerylabs.v4md.test.queries.IDStringPropertyEqualityError, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.IDStringPropertyEqualityError (visibility: PUBLIC, simpleName: IDStringPropertyEqualityError, identifier: com.incquerylabs.v4md.test.queries.IDStringPropertyEqualityError, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static IDStringPropertyEqualityError INSTANCE = new IDStringPropertyEqualityError();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static IDStringPropertyEqualityError.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_elem = new PParameter("elem", "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_property = new PParameter("property", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Property")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_elem, parameter_property);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.IDStringPropertyEqualityError";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("elem","property");
- }
-
- @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_elem = body.getOrCreateVariableByName("elem");
- PVariable var_property = body.getOrCreateVariableByName("property");
- PVariable var_otherElement = body.getOrCreateVariableByName("otherElement");
- new TypeConstraint(body, Tuples.flatTupleOf(var_elem), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_property), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Property")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_elem, parameter_elem),
- new ExportedParameter(body, var_property, parameter_property)
- ));
- // find PropertyStringValueEquals(elem, otherElement, property)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_elem, var_otherElement, var_property), PropertyStringValueEquals.instance().getInternalQueryRepresentation());
- // elem != otherElement
- new Inequality(body, var_elem, var_otherElement);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/MultipleInheritanceBlock.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/MultipleInheritanceBlock.java
deleted file mode 100644
index 5c99150..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/MultipleInheritanceBlock.java
+++ /dev/null
@@ -1,719 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Block_With_More_than_1_Parent.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.GetSuperClass;
-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.Inequality;
-import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
-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 MultipleInheritanceBlock(block : Class, parent1 : Class){
- * Class.appliedStereotypeInstance.classifier.name(block, "Block");
- * find getSuperClass(block, parent1);
- * find getSuperClass(block, parent2);
- * parent1 != parent2;
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class MultipleInheritanceBlock extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.MultipleInheritanceBlock 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 fBlock;
-
- private com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class fParent1;
-
- private static List parameterNames = makeImmutableList("block", "parent1");
-
- private Match(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- this.fBlock = pBlock;
- this.fParent1 = pParent1;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("block".equals(parameterName)) return this.fBlock;
- if ("parent1".equals(parameterName)) return this.fParent1;
- return null;
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getBlock() {
- return this.fBlock;
- }
-
- public com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class getParent1() {
- return this.fParent1;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("block".equals(parameterName) ) {
- this.fBlock = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- if ("parent1".equals(parameterName) ) {
- this.fParent1 = (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) newValue;
- return true;
- }
- return false;
- }
-
- public void setBlock(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fBlock = pBlock;
- }
-
- public void setParent1(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fParent1 = pParent1;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.MultipleInheritanceBlock";
- }
-
- @Override
- public List parameterNames() {
- return MultipleInheritanceBlock.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fBlock, fParent1};
- }
-
- @Override
- public MultipleInheritanceBlock.Match toImmutable() {
- return isMutable() ? newMatch(fBlock, fParent1) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"block\"=" + prettyPrintValue(fBlock) + ", ");
- result.append("\"parent1\"=" + prettyPrintValue(fParent1));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fBlock, fParent1);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof MultipleInheritanceBlock.Match)) {
- MultipleInheritanceBlock.Match other = (MultipleInheritanceBlock.Match) obj;
- return Objects.equals(fBlock, other.fBlock) && Objects.equals(fParent1, other.fParent1);
- } 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 MultipleInheritanceBlock specification() {
- return MultipleInheritanceBlock.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 MultipleInheritanceBlock.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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pParent1 the fixed value of pattern parameter parent1, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static MultipleInheritanceBlock.Match newMutableMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- return new Mutable(pBlock, pParent1);
- }
-
- /**
- * 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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pParent1 the fixed value of pattern parameter parent1, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static MultipleInheritanceBlock.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- return new Immutable(pBlock, pParent1);
- }
-
- private static final class Mutable extends MultipleInheritanceBlock.Match {
- Mutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- super(pBlock, pParent1);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends MultipleInheritanceBlock.Match {
- Immutable(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- super(pBlock, pParent1);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.MultipleInheritanceBlock 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 MultipleInheritanceBlock(block : Class, parent1 : Class){
- * Class.appliedStereotypeInstance.classifier.name(block, "Block");
- * find getSuperClass(block, parent1);
- * find getSuperClass(block, parent2);
- * parent1 != parent2;
- * }
- *
- *
- * @see Match
- * @see MultipleInheritanceBlock
- *
- */
- 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 MultipleInheritanceBlock.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 MultipleInheritanceBlock.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_BLOCK = 0;
-
- private final static int POSITION_PARENT1 = 1;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(MultipleInheritanceBlock.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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pParent1 the fixed value of pattern parameter parent1, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- return rawStreamAllMatches(new Object[]{pBlock, pParent1}).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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pParent1 the fixed value of pattern parameter parent1, 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 pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- return rawStreamAllMatches(new Object[]{pBlock, pParent1});
- }
-
- /**
- * 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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pParent1 the fixed value of pattern parameter parent1, 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 pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- return rawGetOneArbitraryMatch(new Object[]{pBlock, pParent1});
- }
-
- /**
- * 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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pParent1 the fixed value of pattern parameter parent1, 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 pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- return rawHasMatch(new Object[]{pBlock, pParent1});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pParent1 the fixed value of pattern parameter parent1, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- return rawCountMatches(new Object[]{pBlock, pParent1});
- }
-
- /**
- * 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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pParent1 the fixed value of pattern parameter parent1, 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 pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1, final Consumer super MultipleInheritanceBlock.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pBlock, pParent1}, 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 pBlock the fixed value of pattern parameter block, or null if not bound.
- * @param pParent1 the fixed value of pattern parameter parent1, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public MultipleInheritanceBlock.Match newMatch(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock, final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- return MultipleInheritanceBlock.Match.newMatch(pBlock, pParent1);
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfblock(final Object[] parameters) {
- return rawStreamAllValues(POSITION_BLOCK, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfblock() {
- return rawStreamAllValuesOfblock(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfblock() {
- return rawStreamAllValuesOfblock(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- *
- * 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 streamAllValuesOfblock(final MultipleInheritanceBlock.Match partialMatch) {
- return rawStreamAllValuesOfblock(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- *
- * 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 streamAllValuesOfblock(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- return rawStreamAllValuesOfblock(new Object[]{null, pParent1});
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfblock(final MultipleInheritanceBlock.Match partialMatch) {
- return rawStreamAllValuesOfblock(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for block.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfblock(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pParent1) {
- return rawStreamAllValuesOfblock(new Object[]{null, pParent1}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for parent1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfparent1(final Object[] parameters) {
- return rawStreamAllValues(POSITION_PARENT1, parameters).map(com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for parent1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfparent1() {
- return rawStreamAllValuesOfparent1(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for parent1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfparent1() {
- return rawStreamAllValuesOfparent1(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for parent1.
- *
- * 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 streamAllValuesOfparent1(final MultipleInheritanceBlock.Match partialMatch) {
- return rawStreamAllValuesOfparent1(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for parent1.
- *
- * 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 streamAllValuesOfparent1(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock) {
- return rawStreamAllValuesOfparent1(new Object[]{pBlock, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for parent1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfparent1(final MultipleInheritanceBlock.Match partialMatch) {
- return rawStreamAllValuesOfparent1(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for parent1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfparent1(final com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class pBlock) {
- return rawStreamAllValuesOfparent1(new Object[]{pBlock, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected MultipleInheritanceBlock.Match tupleToMatch(final Tuple t) {
- try {
- return MultipleInheritanceBlock.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_BLOCK), (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) t.get(POSITION_PARENT1));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected MultipleInheritanceBlock.Match arrayToMatch(final Object[] match) {
- try {
- return MultipleInheritanceBlock.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_BLOCK], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_PARENT1]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected MultipleInheritanceBlock.Match arrayToMatchMutable(final Object[] match) {
- try {
- return MultipleInheritanceBlock.Match.newMutableMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_BLOCK], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) match[POSITION_PARENT1]);
- } 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 MultipleInheritanceBlock.instance();
- }
- }
-
- private MultipleInheritanceBlock() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static MultipleInheritanceBlock instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected MultipleInheritanceBlock.Matcher instantiate(final ViatraQueryEngine engine) {
- return MultipleInheritanceBlock.Matcher.on(engine);
- }
-
- @Override
- public MultipleInheritanceBlock.Matcher instantiate() {
- return MultipleInheritanceBlock.Matcher.create();
- }
-
- @Override
- public MultipleInheritanceBlock.Match newEmptyMatch() {
- return MultipleInheritanceBlock.Match.newEmptyMatch();
- }
-
- @Override
- public MultipleInheritanceBlock.Match newMatch(final Object... parameters) {
- return MultipleInheritanceBlock.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class) parameters[1]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.MultipleInheritanceBlock (visibility: PUBLIC, simpleName: MultipleInheritanceBlock, identifier: com.incquerylabs.v4md.test.queries.MultipleInheritanceBlock, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.MultipleInheritanceBlock (visibility: PUBLIC, simpleName: MultipleInheritanceBlock, identifier: com.incquerylabs.v4md.test.queries.MultipleInheritanceBlock, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static MultipleInheritanceBlock INSTANCE = new MultipleInheritanceBlock();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static MultipleInheritanceBlock.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_block = new PParameter("block", "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 PParameter parameter_parent1 = new PParameter("parent1", "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_block, parameter_parent1);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.MultipleInheritanceBlock";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("block","parent1");
- }
-
- @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_block = body.getOrCreateVariableByName("block");
- PVariable var_parent1 = body.getOrCreateVariableByName("parent1");
- PVariable var_parent2 = body.getOrCreateVariableByName("parent2");
- new TypeConstraint(body, Tuples.flatTupleOf(var_block), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_parent1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Class")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_block, parameter_block),
- new ExportedParameter(body, var_parent1, parameter_parent1)
- ));
- // Class.appliedStereotypeInstance.classifier.name(block, "Block")
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new ConstantValue(body, var__virtual_0_, "Block");
- new TypeConstraint(body, Tuples.flatTupleOf(var_block), 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_block, 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_);
- // find getSuperClass(block, parent1)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_block, var_parent1), GetSuperClass.instance().getInternalQueryRepresentation());
- // find getSuperClass(block, parent2)
- new PositivePatternCall(body, Tuples.flatTupleOf(var_block, var_parent2), GetSuperClass.instance().getInternalQueryRepresentation());
- // parent1 != parent2
- new Inequality(body, var_parent1, var_parent2);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Non_Unique_Names.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Non_Unique_Names.java
deleted file mode 100644
index 9e30e0c..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Non_Unique_Names.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Non_Unique_Names.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.IDStringPropertyEqualityError;
-import com.incquerylabs.v4md.test.queries.PropertyStringValueEquals;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
-
-/**
- * A pattern group formed of all public patterns defined in Non_Unique_Names.vql.
- *
- * Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare
- * a VIATRA Query engine for matching all patterns originally defined in file Non_Unique_Names.vql,
- * in order to achieve better performance than one-by-one on-demand matcher initialization.
- *
- *
From package com.incquerylabs.v4md.test.queries, the group contains the definition of the following patterns:
- * - IDStringPropertyEqualityError
- * - PropertyStringValueEquals
- *
- *
- * @see IQueryGroup
- *
- */
-@SuppressWarnings("all")
-public final class Non_Unique_Names extends BaseGeneratedPatternGroup {
- /**
- * Access the pattern group.
- *
- * @return the singleton instance of the group
- * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
- *
- */
- public static Non_Unique_Names instance() {
- if (INSTANCE == null) {
- INSTANCE = new Non_Unique_Names();
- }
- return INSTANCE;
- }
-
- private static Non_Unique_Names INSTANCE;
-
- private Non_Unique_Names() {
- querySpecifications.add(IDStringPropertyEqualityError.instance());
- querySpecifications.add(PropertyStringValueEquals.instance());
- }
-
- public IDStringPropertyEqualityError getIDStringPropertyEqualityError() {
- return IDStringPropertyEqualityError.instance();
- }
-
- public IDStringPropertyEqualityError.Matcher getIDStringPropertyEqualityError(final ViatraQueryEngine engine) {
- return IDStringPropertyEqualityError.Matcher.on(engine);
- }
-
- public PropertyStringValueEquals getPropertyStringValueEquals() {
- return PropertyStringValueEquals.instance();
- }
-
- public PropertyStringValueEquals.Matcher getPropertyStringValueEquals(final ViatraQueryEngine engine) {
- return PropertyStringValueEquals.Matcher.on(engine);
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/NotReachableFromInit.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/NotReachableFromInit.java
deleted file mode 100644
index 8541499..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/NotReachableFromInit.java
+++ /dev/null
@@ -1,536 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Unreachable_States.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.ReachableFromInitState;
-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.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:
- *
- * pattern notReachableFromInit(state : State){
- * neg find reachableFromInitState(state);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class NotReachableFromInit extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.notReachableFromInit 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) {
- if ("state".equals(parameterName)) return this.fState;
- 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.v4md.test.queries.notReachableFromInit";
- }
-
- @Override
- public List parameterNames() {
- return NotReachableFromInit.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fState};
- }
-
- @Override
- public NotReachableFromInit.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 NotReachableFromInit.Match)) {
- NotReachableFromInit.Match other = (NotReachableFromInit.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 NotReachableFromInit specification() {
- return NotReachableFromInit.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 NotReachableFromInit.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 NotReachableFromInit.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 NotReachableFromInit.Match newMatch(final State pState) {
- return new Immutable(pState);
- }
-
- private static final class Mutable extends NotReachableFromInit.Match {
- Mutable(final State pState) {
- super(pState);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends NotReachableFromInit.Match {
- Immutable(final State pState) {
- super(pState);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.notReachableFromInit 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 notReachableFromInit(state : State){
- * neg find reachableFromInitState(state);
- * }
- *
- *
- * @see Match
- * @see NotReachableFromInit
- *
- */
- 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 NotReachableFromInit.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 NotReachableFromInit.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_STATE = 0;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NotReachableFromInit.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 NotReachableFromInit.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 NotReachableFromInit.Match newMatch(final State pState) {
- return NotReachableFromInit.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 NotReachableFromInit.Match tupleToMatch(final Tuple t) {
- try {
- return NotReachableFromInit.Match.newMatch((State) t.get(POSITION_STATE));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NotReachableFromInit.Match arrayToMatch(final Object[] match) {
- try {
- return NotReachableFromInit.Match.newMatch((State) match[POSITION_STATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected NotReachableFromInit.Match arrayToMatchMutable(final Object[] match) {
- try {
- return NotReachableFromInit.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 NotReachableFromInit.instance();
- }
- }
-
- private NotReachableFromInit() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static NotReachableFromInit instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected NotReachableFromInit.Matcher instantiate(final ViatraQueryEngine engine) {
- return NotReachableFromInit.Matcher.on(engine);
- }
-
- @Override
- public NotReachableFromInit.Matcher instantiate() {
- return NotReachableFromInit.Matcher.create();
- }
-
- @Override
- public NotReachableFromInit.Match newEmptyMatch() {
- return NotReachableFromInit.Match.newEmptyMatch();
- }
-
- @Override
- public NotReachableFromInit.Match newMatch(final Object... parameters) {
- return NotReachableFromInit.Match.newMatch((com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.NotReachableFromInit (visibility: PUBLIC, simpleName: NotReachableFromInit, identifier: com.incquerylabs.v4md.test.queries.NotReachableFromInit, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.NotReachableFromInit (visibility: PUBLIC, simpleName: NotReachableFromInit, identifier: com.incquerylabs.v4md.test.queries.NotReachableFromInit, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static NotReachableFromInit INSTANCE = new NotReachableFromInit();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static NotReachableFromInit.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.v4md.test.queries.notReachableFromInit";
- }
-
- @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");
- 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)
- ));
- // neg find reachableFromInitState(state)
- new NegativePatternCall(body, Tuples.flatTupleOf(var_state), ReachableFromInitState.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Pattern_Constraints.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Pattern_Constraints.java
deleted file mode 100644
index d312733..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Pattern_Constraints.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Pattern_Constraints.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.ClassesWithSameNamedProperty;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
-
-/**
- * A pattern group formed of all public patterns defined in Pattern_Constraints.vql.
- *
- * Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare
- * a VIATRA Query engine for matching all patterns originally defined in file Pattern_Constraints.vql,
- * in order to achieve better performance than one-by-one on-demand matcher initialization.
- *
- *
From package com.incquerylabs.v4md.test.queries, the group contains the definition of the following patterns:
- * - classesWithSameNamedProperty
- *
- *
- * @see IQueryGroup
- *
- */
-@SuppressWarnings("all")
-public final class Pattern_Constraints extends BaseGeneratedPatternGroup {
- /**
- * Access the pattern group.
- *
- * @return the singleton instance of the group
- * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
- *
- */
- public static Pattern_Constraints instance() {
- if (INSTANCE == null) {
- INSTANCE = new Pattern_Constraints();
- }
- return INSTANCE;
- }
-
- private static Pattern_Constraints INSTANCE;
-
- private Pattern_Constraints() {
- querySpecifications.add(ClassesWithSameNamedProperty.instance());
- }
-
- public ClassesWithSameNamedProperty getClassesWithSameNamedProperty() {
- return ClassesWithSameNamedProperty.instance();
- }
-
- public ClassesWithSameNamedProperty.Matcher getClassesWithSameNamedProperty(final ViatraQueryEngine engine) {
- return ClassesWithSameNamedProperty.Matcher.on(engine);
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/PortConnections.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/PortConnections.java
deleted file mode 100644
index 61c2c69..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/PortConnections.java
+++ /dev/null
@@ -1,836 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Port_Connections.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.nomagic.uml2.ext.magicdraw.compositestructures.mdinternalstructures.Connector;
-import com.nomagic.uml2.ext.magicdraw.compositestructures.mdports.Port;
-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.basicdeferred.Inequality;
-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 PortConnections(port1 : Port, connector : Connector, port2 : Port) {
- * Connector.end(connector, end1);
- * Connector.end(connector, end2);
- *
- * Port.end(port1, end1);
- * Port.end(port2, end2);
- *
- * port1 != port2;
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class PortConnections extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.PortConnections 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 Port fPort1;
-
- private Connector fConnector;
-
- private Port fPort2;
-
- private static List parameterNames = makeImmutableList("port1", "connector", "port2");
-
- private Match(final Port pPort1, final Connector pConnector, final Port pPort2) {
- this.fPort1 = pPort1;
- this.fConnector = pConnector;
- this.fPort2 = pPort2;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("port1".equals(parameterName)) return this.fPort1;
- if ("connector".equals(parameterName)) return this.fConnector;
- if ("port2".equals(parameterName)) return this.fPort2;
- return null;
- }
-
- public Port getPort1() {
- return this.fPort1;
- }
-
- public Connector getConnector() {
- return this.fConnector;
- }
-
- public Port getPort2() {
- return this.fPort2;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("port1".equals(parameterName) ) {
- this.fPort1 = (Port) newValue;
- return true;
- }
- if ("connector".equals(parameterName) ) {
- this.fConnector = (Connector) newValue;
- return true;
- }
- if ("port2".equals(parameterName) ) {
- this.fPort2 = (Port) newValue;
- return true;
- }
- return false;
- }
-
- public void setPort1(final Port pPort1) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fPort1 = pPort1;
- }
-
- public void setConnector(final Connector pConnector) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fConnector = pConnector;
- }
-
- public void setPort2(final Port pPort2) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fPort2 = pPort2;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.PortConnections";
- }
-
- @Override
- public List parameterNames() {
- return PortConnections.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fPort1, fConnector, fPort2};
- }
-
- @Override
- public PortConnections.Match toImmutable() {
- return isMutable() ? newMatch(fPort1, fConnector, fPort2) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"port1\"=" + prettyPrintValue(fPort1) + ", ");
- result.append("\"connector\"=" + prettyPrintValue(fConnector) + ", ");
- result.append("\"port2\"=" + prettyPrintValue(fPort2));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fPort1, fConnector, fPort2);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof PortConnections.Match)) {
- PortConnections.Match other = (PortConnections.Match) obj;
- return Objects.equals(fPort1, other.fPort1) && Objects.equals(fConnector, other.fConnector) && Objects.equals(fPort2, other.fPort2);
- } 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 PortConnections specification() {
- return PortConnections.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 PortConnections.Match newEmptyMatch() {
- return new Mutable(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 pPort1 the fixed value of pattern parameter port1, or null if not bound.
- * @param pConnector the fixed value of pattern parameter connector, or null if not bound.
- * @param pPort2 the fixed value of pattern parameter port2, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static PortConnections.Match newMutableMatch(final Port pPort1, final Connector pConnector, final Port pPort2) {
- return new Mutable(pPort1, pConnector, pPort2);
- }
-
- /**
- * 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 pPort1 the fixed value of pattern parameter port1, or null if not bound.
- * @param pConnector the fixed value of pattern parameter connector, or null if not bound.
- * @param pPort2 the fixed value of pattern parameter port2, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static PortConnections.Match newMatch(final Port pPort1, final Connector pConnector, final Port pPort2) {
- return new Immutable(pPort1, pConnector, pPort2);
- }
-
- private static final class Mutable extends PortConnections.Match {
- Mutable(final Port pPort1, final Connector pConnector, final Port pPort2) {
- super(pPort1, pConnector, pPort2);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends PortConnections.Match {
- Immutable(final Port pPort1, final Connector pConnector, final Port pPort2) {
- super(pPort1, pConnector, pPort2);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.PortConnections 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 PortConnections(port1 : Port, connector : Connector, port2 : Port) {
- * Connector.end(connector, end1);
- * Connector.end(connector, end2);
- *
- * Port.end(port1, end1);
- * Port.end(port2, end2);
- *
- * port1 != port2;
- * }
- *
- *
- * @see Match
- * @see PortConnections
- *
- */
- 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 PortConnections.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 PortConnections.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_PORT1 = 0;
-
- private final static int POSITION_CONNECTOR = 1;
-
- private final static int POSITION_PORT2 = 2;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(PortConnections.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 pPort1 the fixed value of pattern parameter port1, or null if not bound.
- * @param pConnector the fixed value of pattern parameter connector, or null if not bound.
- * @param pPort2 the fixed value of pattern parameter port2, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final Port pPort1, final Connector pConnector, final Port pPort2) {
- return rawStreamAllMatches(new Object[]{pPort1, pConnector, pPort2}).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 pPort1 the fixed value of pattern parameter port1, or null if not bound.
- * @param pConnector the fixed value of pattern parameter connector, or null if not bound.
- * @param pPort2 the fixed value of pattern parameter port2, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final Port pPort1, final Connector pConnector, final Port pPort2) {
- return rawStreamAllMatches(new Object[]{pPort1, pConnector, pPort2});
- }
-
- /**
- * 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 pPort1 the fixed value of pattern parameter port1, or null if not bound.
- * @param pConnector the fixed value of pattern parameter connector, or null if not bound.
- * @param pPort2 the fixed value of pattern parameter port2, or null if not bound.
- * @return a match represented as a Match object, or null if no match is found.
- *
- */
- public Optional getOneArbitraryMatch(final Port pPort1, final Connector pConnector, final Port pPort2) {
- return rawGetOneArbitraryMatch(new Object[]{pPort1, pConnector, pPort2});
- }
-
- /**
- * 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 pPort1 the fixed value of pattern parameter port1, or null if not bound.
- * @param pConnector the fixed value of pattern parameter connector, or null if not bound.
- * @param pPort2 the fixed value of pattern parameter port2, or null if not bound.
- * @return true if the input is a valid (partial) match of the pattern.
- *
- */
- public boolean hasMatch(final Port pPort1, final Connector pConnector, final Port pPort2) {
- return rawHasMatch(new Object[]{pPort1, pConnector, pPort2});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pPort1 the fixed value of pattern parameter port1, or null if not bound.
- * @param pConnector the fixed value of pattern parameter connector, or null if not bound.
- * @param pPort2 the fixed value of pattern parameter port2, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final Port pPort1, final Connector pConnector, final Port pPort2) {
- return rawCountMatches(new Object[]{pPort1, pConnector, pPort2});
- }
-
- /**
- * 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 pPort1 the fixed value of pattern parameter port1, or null if not bound.
- * @param pConnector the fixed value of pattern parameter connector, or null if not bound.
- * @param pPort2 the fixed value of pattern parameter port2, 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 Port pPort1, final Connector pConnector, final Port pPort2, final Consumer super PortConnections.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pPort1, pConnector, pPort2}, 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 pPort1 the fixed value of pattern parameter port1, or null if not bound.
- * @param pConnector the fixed value of pattern parameter connector, or null if not bound.
- * @param pPort2 the fixed value of pattern parameter port2, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public PortConnections.Match newMatch(final Port pPort1, final Connector pConnector, final Port pPort2) {
- return PortConnections.Match.newMatch(pPort1, pConnector, pPort2);
- }
-
- /**
- * Retrieve the set of values that occur in matches for port1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfport1(final Object[] parameters) {
- return rawStreamAllValues(POSITION_PORT1, parameters).map(Port.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for port1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfport1() {
- return rawStreamAllValuesOfport1(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for port1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfport1() {
- return rawStreamAllValuesOfport1(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for port1.
- *
- * 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 streamAllValuesOfport1(final PortConnections.Match partialMatch) {
- return rawStreamAllValuesOfport1(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for port1.
- *
- * 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 streamAllValuesOfport1(final Connector pConnector, final Port pPort2) {
- return rawStreamAllValuesOfport1(new Object[]{null, pConnector, pPort2});
- }
-
- /**
- * Retrieve the set of values that occur in matches for port1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfport1(final PortConnections.Match partialMatch) {
- return rawStreamAllValuesOfport1(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for port1.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfport1(final Connector pConnector, final Port pPort2) {
- return rawStreamAllValuesOfport1(new Object[]{null, pConnector, pPort2}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for connector.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfconnector(final Object[] parameters) {
- return rawStreamAllValues(POSITION_CONNECTOR, parameters).map(Connector.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for connector.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfconnector() {
- return rawStreamAllValuesOfconnector(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for connector.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfconnector() {
- return rawStreamAllValuesOfconnector(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for connector.
- *
- * 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 streamAllValuesOfconnector(final PortConnections.Match partialMatch) {
- return rawStreamAllValuesOfconnector(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for connector.
- *
- * 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 streamAllValuesOfconnector(final Port pPort1, final Port pPort2) {
- return rawStreamAllValuesOfconnector(new Object[]{pPort1, null, pPort2});
- }
-
- /**
- * Retrieve the set of values that occur in matches for connector.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfconnector(final PortConnections.Match partialMatch) {
- return rawStreamAllValuesOfconnector(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for connector.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfconnector(final Port pPort1, final Port pPort2) {
- return rawStreamAllValuesOfconnector(new Object[]{pPort1, null, pPort2}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for port2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfport2(final Object[] parameters) {
- return rawStreamAllValues(POSITION_PORT2, parameters).map(Port.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for port2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfport2() {
- return rawStreamAllValuesOfport2(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for port2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfport2() {
- return rawStreamAllValuesOfport2(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for port2.
- *
- * 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 streamAllValuesOfport2(final PortConnections.Match partialMatch) {
- return rawStreamAllValuesOfport2(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for port2.
- *
- * 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 streamAllValuesOfport2(final Port pPort1, final Connector pConnector) {
- return rawStreamAllValuesOfport2(new Object[]{pPort1, pConnector, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for port2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfport2(final PortConnections.Match partialMatch) {
- return rawStreamAllValuesOfport2(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for port2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfport2(final Port pPort1, final Connector pConnector) {
- return rawStreamAllValuesOfport2(new Object[]{pPort1, pConnector, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected PortConnections.Match tupleToMatch(final Tuple t) {
- try {
- return PortConnections.Match.newMatch((Port) t.get(POSITION_PORT1), (Connector) t.get(POSITION_CONNECTOR), (Port) t.get(POSITION_PORT2));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected PortConnections.Match arrayToMatch(final Object[] match) {
- try {
- return PortConnections.Match.newMatch((Port) match[POSITION_PORT1], (Connector) match[POSITION_CONNECTOR], (Port) match[POSITION_PORT2]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected PortConnections.Match arrayToMatchMutable(final Object[] match) {
- try {
- return PortConnections.Match.newMutableMatch((Port) match[POSITION_PORT1], (Connector) match[POSITION_CONNECTOR], (Port) match[POSITION_PORT2]);
- } 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 PortConnections.instance();
- }
- }
-
- private PortConnections() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static PortConnections instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected PortConnections.Matcher instantiate(final ViatraQueryEngine engine) {
- return PortConnections.Matcher.on(engine);
- }
-
- @Override
- public PortConnections.Matcher instantiate() {
- return PortConnections.Matcher.create();
- }
-
- @Override
- public PortConnections.Match newEmptyMatch() {
- return PortConnections.Match.newEmptyMatch();
- }
-
- @Override
- public PortConnections.Match newMatch(final Object... parameters) {
- return PortConnections.Match.newMatch((com.nomagic.uml2.ext.magicdraw.compositestructures.mdports.Port) parameters[0], (com.nomagic.uml2.ext.magicdraw.compositestructures.mdinternalstructures.Connector) parameters[1], (com.nomagic.uml2.ext.magicdraw.compositestructures.mdports.Port) parameters[2]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.PortConnections (visibility: PUBLIC, simpleName: PortConnections, identifier: com.incquerylabs.v4md.test.queries.PortConnections, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.PortConnections (visibility: PUBLIC, simpleName: PortConnections, identifier: com.incquerylabs.v4md.test.queries.PortConnections, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static PortConnections INSTANCE = new PortConnections();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static PortConnections.GeneratedPQuery INSTANCE = new GeneratedPQuery();
-
- private final PParameter parameter_port1 = new PParameter("port1", "com.nomagic.uml2.ext.magicdraw.compositestructures.mdports.Port", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Port")), PParameterDirection.INOUT);
-
- private final PParameter parameter_connector = new PParameter("connector", "com.nomagic.uml2.ext.magicdraw.compositestructures.mdinternalstructures.Connector", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Connector")), PParameterDirection.INOUT);
-
- private final PParameter parameter_port2 = new PParameter("port2", "com.nomagic.uml2.ext.magicdraw.compositestructures.mdports.Port", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Port")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_port1, parameter_connector, parameter_port2);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.PortConnections";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("port1","connector","port2");
- }
-
- @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_port1 = body.getOrCreateVariableByName("port1");
- PVariable var_connector = body.getOrCreateVariableByName("connector");
- PVariable var_port2 = body.getOrCreateVariableByName("port2");
- PVariable var_end1 = body.getOrCreateVariableByName("end1");
- PVariable var_end2 = body.getOrCreateVariableByName("end2");
- new TypeConstraint(body, Tuples.flatTupleOf(var_port1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Port")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_connector), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Connector")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_port2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Port")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_port1, parameter_port1),
- new ExportedParameter(body, var_connector, parameter_connector),
- new ExportedParameter(body, var_port2, parameter_port2)
- ));
- // Connector.end(connector, end1)
- new TypeConstraint(body, Tuples.flatTupleOf(var_connector), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Connector")));
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_connector, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Connector", "end")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "ConnectorEnd")));
- new Equality(body, var__virtual_0_, var_end1);
- // Connector.end(connector, end2)
- new TypeConstraint(body, Tuples.flatTupleOf(var_connector), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Connector")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_connector, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Connector", "end")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "ConnectorEnd")));
- new Equality(body, var__virtual_1_, var_end2);
- // Port.end(port1, end1)
- new TypeConstraint(body, Tuples.flatTupleOf(var_port1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Port")));
- PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_port1, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "ConnectableElement", "end")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "ConnectorEnd")));
- new Equality(body, var__virtual_2_, var_end1);
- // Port.end(port2, end2)
- new TypeConstraint(body, Tuples.flatTupleOf(var_port2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Port")));
- PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_port2, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "ConnectableElement", "end")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "ConnectorEnd")));
- new Equality(body, var__virtual_3_, var_end2);
- // port1 != port2
- new Inequality(body, var_port1, var_port2);
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Port_Connections.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Port_Connections.java
deleted file mode 100644
index b8b4a2a..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/Port_Connections.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Port_Connections.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.PortConnections;
-import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
-import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup;
-
-/**
- * A pattern group formed of all public patterns defined in Port_Connections.vql.
- *
- * Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare
- * a VIATRA Query engine for matching all patterns originally defined in file Port_Connections.vql,
- * in order to achieve better performance than one-by-one on-demand matcher initialization.
- *
- *
From package com.incquerylabs.v4md.test.queries, the group contains the definition of the following patterns:
- *
- * @see IQueryGroup
- *
- */
-@SuppressWarnings("all")
-public final class Port_Connections extends BaseGeneratedPatternGroup {
- /**
- * Access the pattern group.
- *
- * @return the singleton instance of the group
- * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications
- *
- */
- public static Port_Connections instance() {
- if (INSTANCE == null) {
- INSTANCE = new Port_Connections();
- }
- return INSTANCE;
- }
-
- private static Port_Connections INSTANCE;
-
- private Port_Connections() {
- querySpecifications.add(PortConnections.instance());
- }
-
- public PortConnections getPortConnections() {
- return PortConnections.instance();
- }
-
- public PortConnections.Matcher getPortConnections(final ViatraQueryEngine engine) {
- return PortConnections.Matcher.on(engine);
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/PropertyStringValueEquals.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/PropertyStringValueEquals.java
deleted file mode 100644
index b23a53d..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/PropertyStringValueEquals.java
+++ /dev/null
@@ -1,905 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Non_Unique_Names.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement;
-import com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property;
-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.Inequality;
-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:
- *
- * Detects NamedElement pairs, where the values of the same STRING ID property are equal
- *
- * pattern PropertyStringValueEquals(element : NamedElement, element2 : NamedElement, property : Property){
- * element != element2;
- * Property.isID(property, true);
- * NamedElement.appliedStereotypeInstance.slot(element, slot);
- * Slot.definingFeature(slot, property);
- *
- * NamedElement.appliedStereotypeInstance.slot(element2, slot2);
- * Slot.definingFeature(slot2, property);
- *
- * Slot.value(slot, spec1);
- * Slot.value(slot2, spec2);
- *
- * LiteralString.value(spec1, val1);
- * LiteralString.value(spec2, val2);
- * val1 == val2;
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class PropertyStringValueEquals extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.PropertyStringValueEquals 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 NamedElement fElement2;
-
- private Property fProperty;
-
- private static List parameterNames = makeImmutableList("element", "element2", "property");
-
- private Match(final NamedElement pElement, final NamedElement pElement2, final Property pProperty) {
- this.fElement = pElement;
- this.fElement2 = pElement2;
- this.fProperty = pProperty;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("element".equals(parameterName)) return this.fElement;
- if ("element2".equals(parameterName)) return this.fElement2;
- if ("property".equals(parameterName)) return this.fProperty;
- return null;
- }
-
- public NamedElement getElement() {
- return this.fElement;
- }
-
- public NamedElement getElement2() {
- return this.fElement2;
- }
-
- public Property getProperty() {
- return this.fProperty;
- }
-
- @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 ("element2".equals(parameterName) ) {
- this.fElement2 = (NamedElement) newValue;
- return true;
- }
- if ("property".equals(parameterName) ) {
- this.fProperty = (Property) newValue;
- return true;
- }
- return false;
- }
-
- public void setElement(final NamedElement pElement) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fElement = pElement;
- }
-
- public void setElement2(final NamedElement pElement2) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fElement2 = pElement2;
- }
-
- public void setProperty(final Property pProperty) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fProperty = pProperty;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.PropertyStringValueEquals";
- }
-
- @Override
- public List parameterNames() {
- return PropertyStringValueEquals.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fElement, fElement2, fProperty};
- }
-
- @Override
- public PropertyStringValueEquals.Match toImmutable() {
- return isMutable() ? newMatch(fElement, fElement2, fProperty) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"element\"=" + prettyPrintValue(fElement) + ", ");
- result.append("\"element2\"=" + prettyPrintValue(fElement2) + ", ");
- result.append("\"property\"=" + prettyPrintValue(fProperty));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fElement, fElement2, fProperty);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof PropertyStringValueEquals.Match)) {
- PropertyStringValueEquals.Match other = (PropertyStringValueEquals.Match) obj;
- return Objects.equals(fElement, other.fElement) && Objects.equals(fElement2, other.fElement2) && Objects.equals(fProperty, other.fProperty);
- } 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 PropertyStringValueEquals specification() {
- return PropertyStringValueEquals.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 PropertyStringValueEquals.Match newEmptyMatch() {
- return new Mutable(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 pElement the fixed value of pattern parameter element, or null if not bound.
- * @param pElement2 the fixed value of pattern parameter element2, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return the new, mutable (partial) match object.
- *
- */
- public static PropertyStringValueEquals.Match newMutableMatch(final NamedElement pElement, final NamedElement pElement2, final Property pProperty) {
- return new Mutable(pElement, pElement2, pProperty);
- }
-
- /**
- * 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 pElement2 the fixed value of pattern parameter element2, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public static PropertyStringValueEquals.Match newMatch(final NamedElement pElement, final NamedElement pElement2, final Property pProperty) {
- return new Immutable(pElement, pElement2, pProperty);
- }
-
- private static final class Mutable extends PropertyStringValueEquals.Match {
- Mutable(final NamedElement pElement, final NamedElement pElement2, final Property pProperty) {
- super(pElement, pElement2, pProperty);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends PropertyStringValueEquals.Match {
- Immutable(final NamedElement pElement, final NamedElement pElement2, final Property pProperty) {
- super(pElement, pElement2, pProperty);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.PropertyStringValueEquals 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:
- *
- * Detects NamedElement pairs, where the values of the same STRING ID property are equal
- *
- * pattern PropertyStringValueEquals(element : NamedElement, element2 : NamedElement, property : Property){
- * element != element2;
- * Property.isID(property, true);
- * NamedElement.appliedStereotypeInstance.slot(element, slot);
- * Slot.definingFeature(slot, property);
- *
- * NamedElement.appliedStereotypeInstance.slot(element2, slot2);
- * Slot.definingFeature(slot2, property);
- *
- * Slot.value(slot, spec1);
- * Slot.value(slot2, spec2);
- *
- * LiteralString.value(spec1, val1);
- * LiteralString.value(spec2, val2);
- * val1 == val2;
- * }
- *
- *
- * @see Match
- * @see PropertyStringValueEquals
- *
- */
- 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 PropertyStringValueEquals.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 PropertyStringValueEquals.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_ELEMENT = 0;
-
- private final static int POSITION_ELEMENT2 = 1;
-
- private final static int POSITION_PROPERTY = 2;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(PropertyStringValueEquals.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 pElement2 the fixed value of pattern parameter element2, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return matches represented as a Match object.
- *
- */
- public Collection getAllMatches(final NamedElement pElement, final NamedElement pElement2, final Property pProperty) {
- return rawStreamAllMatches(new Object[]{pElement, pElement2, pProperty}).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 pElement2 the fixed value of pattern parameter element2, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return a stream of matches represented as a Match object.
- *
- */
- public Stream streamAllMatches(final NamedElement pElement, final NamedElement pElement2, final Property pProperty) {
- return rawStreamAllMatches(new Object[]{pElement, pElement2, pProperty});
- }
-
- /**
- * 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 pElement2 the fixed value of pattern parameter element2, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, 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 NamedElement pElement2, final Property pProperty) {
- return rawGetOneArbitraryMatch(new Object[]{pElement, pElement2, pProperty});
- }
-
- /**
- * 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 pElement2 the fixed value of pattern parameter element2, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, 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 NamedElement pElement2, final Property pProperty) {
- return rawHasMatch(new Object[]{pElement, pElement2, pProperty});
- }
-
- /**
- * 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 pElement2 the fixed value of pattern parameter element2, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return the number of pattern matches found.
- *
- */
- public int countMatches(final NamedElement pElement, final NamedElement pElement2, final Property pProperty) {
- return rawCountMatches(new Object[]{pElement, pElement2, pProperty});
- }
-
- /**
- * 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 pElement2 the fixed value of pattern parameter element2, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, 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 NamedElement pElement2, final Property pProperty, final Consumer super PropertyStringValueEquals.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pElement, pElement2, pProperty}, 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 pElement2 the fixed value of pattern parameter element2, or null if not bound.
- * @param pProperty the fixed value of pattern parameter property, or null if not bound.
- * @return the (partial) match object.
- *
- */
- public PropertyStringValueEquals.Match newMatch(final NamedElement pElement, final NamedElement pElement2, final Property pProperty) {
- return PropertyStringValueEquals.Match.newMatch(pElement, pElement2, pProperty);
- }
-
- /**
- * 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 PropertyStringValueEquals.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 NamedElement pElement2, final Property pProperty) {
- return rawStreamAllValuesOfelement(new Object[]{null, pElement2, pProperty});
- }
-
- /**
- * 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 PropertyStringValueEquals.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 NamedElement pElement2, final Property pProperty) {
- return rawStreamAllValuesOfelement(new Object[]{null, pElement2, pProperty}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfelement2(final Object[] parameters) {
- return rawStreamAllValues(POSITION_ELEMENT2, parameters).map(NamedElement.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for element2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelement2() {
- return rawStreamAllValuesOfelement2(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfelement2() {
- return rawStreamAllValuesOfelement2(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element2.
- *
- * 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 streamAllValuesOfelement2(final PropertyStringValueEquals.Match partialMatch) {
- return rawStreamAllValuesOfelement2(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element2.
- *
- * 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 streamAllValuesOfelement2(final NamedElement pElement, final Property pProperty) {
- return rawStreamAllValuesOfelement2(new Object[]{pElement, null, pProperty});
- }
-
- /**
- * Retrieve the set of values that occur in matches for element2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelement2(final PropertyStringValueEquals.Match partialMatch) {
- return rawStreamAllValuesOfelement2(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for element2.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfelement2(final NamedElement pElement, final Property pProperty) {
- return rawStreamAllValuesOfelement2(new Object[]{pElement, null, pProperty}).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfproperty(final Object[] parameters) {
- return rawStreamAllValues(POSITION_PROPERTY, parameters).map(Property.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfproperty() {
- return rawStreamAllValuesOfproperty(emptyArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Stream streamAllValuesOfproperty() {
- return rawStreamAllValuesOfproperty(emptyArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- *
- * 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 streamAllValuesOfproperty(final PropertyStringValueEquals.Match partialMatch) {
- return rawStreamAllValuesOfproperty(partialMatch.toArray());
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- *
- * 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 streamAllValuesOfproperty(final NamedElement pElement, final NamedElement pElement2) {
- return rawStreamAllValuesOfproperty(new Object[]{pElement, pElement2, null});
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfproperty(final PropertyStringValueEquals.Match partialMatch) {
- return rawStreamAllValuesOfproperty(partialMatch.toArray()).collect(Collectors.toSet());
- }
-
- /**
- * Retrieve the set of values that occur in matches for property.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set getAllValuesOfproperty(final NamedElement pElement, final NamedElement pElement2) {
- return rawStreamAllValuesOfproperty(new Object[]{pElement, pElement2, null}).collect(Collectors.toSet());
- }
-
- @Override
- protected PropertyStringValueEquals.Match tupleToMatch(final Tuple t) {
- try {
- return PropertyStringValueEquals.Match.newMatch((NamedElement) t.get(POSITION_ELEMENT), (NamedElement) t.get(POSITION_ELEMENT2), (Property) t.get(POSITION_PROPERTY));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected PropertyStringValueEquals.Match arrayToMatch(final Object[] match) {
- try {
- return PropertyStringValueEquals.Match.newMatch((NamedElement) match[POSITION_ELEMENT], (NamedElement) match[POSITION_ELEMENT2], (Property) match[POSITION_PROPERTY]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected PropertyStringValueEquals.Match arrayToMatchMutable(final Object[] match) {
- try {
- return PropertyStringValueEquals.Match.newMutableMatch((NamedElement) match[POSITION_ELEMENT], (NamedElement) match[POSITION_ELEMENT2], (Property) match[POSITION_PROPERTY]);
- } 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 PropertyStringValueEquals.instance();
- }
- }
-
- private PropertyStringValueEquals() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static PropertyStringValueEquals instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected PropertyStringValueEquals.Matcher instantiate(final ViatraQueryEngine engine) {
- return PropertyStringValueEquals.Matcher.on(engine);
- }
-
- @Override
- public PropertyStringValueEquals.Matcher instantiate() {
- return PropertyStringValueEquals.Matcher.create();
- }
-
- @Override
- public PropertyStringValueEquals.Match newEmptyMatch() {
- return PropertyStringValueEquals.Match.newEmptyMatch();
- }
-
- @Override
- public PropertyStringValueEquals.Match newMatch(final Object... parameters) {
- return PropertyStringValueEquals.Match.newMatch((com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[0], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.NamedElement) parameters[1], (com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property) parameters[2]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.PropertyStringValueEquals (visibility: PUBLIC, simpleName: PropertyStringValueEquals, identifier: com.incquerylabs.v4md.test.queries.PropertyStringValueEquals, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.PropertyStringValueEquals (visibility: PUBLIC, simpleName: PropertyStringValueEquals, identifier: com.incquerylabs.v4md.test.queries.PropertyStringValueEquals, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static PropertyStringValueEquals INSTANCE = new PropertyStringValueEquals();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static PropertyStringValueEquals.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_element2 = new PParameter("element2", "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_property = new PParameter("property", "com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Property", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.nomagic.com/magicdraw/UML/2.5.1", "Property")), PParameterDirection.INOUT);
-
- private final List parameters = Arrays.asList(parameter_element, parameter_element2, parameter_property);
-
- private GeneratedPQuery() {
- super(PVisibility.PUBLIC);
- }
-
- @Override
- public String getFullyQualifiedName() {
- return "com.incquerylabs.v4md.test.queries.PropertyStringValueEquals";
- }
-
- @Override
- public List getParameterNames() {
- return Arrays.asList("element","element2","property");
- }
-
- @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_element2 = body.getOrCreateVariableByName("element2");
- PVariable var_property = body.getOrCreateVariableByName("property");
- PVariable var_slot = body.getOrCreateVariableByName("slot");
- PVariable var_slot2 = body.getOrCreateVariableByName("slot2");
- PVariable var_spec1 = body.getOrCreateVariableByName("spec1");
- PVariable var_spec2 = body.getOrCreateVariableByName("spec2");
- PVariable var_val1 = body.getOrCreateVariableByName("val1");
- PVariable var_val2 = body.getOrCreateVariableByName("val2");
- new TypeConstraint(body, Tuples.flatTupleOf(var_element), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_element2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- new TypeConstraint(body, Tuples.flatTupleOf(var_property), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Property")));
- body.setSymbolicParameters(Arrays.asList(
- new ExportedParameter(body, var_element, parameter_element),
- new ExportedParameter(body, var_element2, parameter_element2),
- new ExportedParameter(body, var_property, parameter_property)
- ));
- // element != element2
- new Inequality(body, var_element, var_element2);
- // Property.isID(property, true)
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new ConstantValue(body, var__virtual_0_, true);
- new TypeConstraint(body, Tuples.flatTupleOf(var_property), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Property")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_property, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Property", "isID")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Boolean")));
- new Equality(body, var__virtual_1_, var__virtual_0_);
- // NamedElement.appliedStereotypeInstance.slot(element, slot)
- new TypeConstraint(body, Tuples.flatTupleOf(var_element), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_element, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Element", "appliedStereotypeInstance")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "InstanceSpecification")));
- 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", "InstanceSpecification", "slot")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Slot")));
- new Equality(body, var__virtual_3_, var_slot);
- // Slot.definingFeature(slot, property)
- new TypeConstraint(body, Tuples.flatTupleOf(var_slot), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Slot")));
- PVariable var__virtual_4_ = body.getOrCreateVariableByName(".virtual{4}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_slot, var__virtual_4_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Slot", "definingFeature")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_4_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "StructuralFeature")));
- new Equality(body, var__virtual_4_, var_property);
- // NamedElement.appliedStereotypeInstance.slot(element2, slot2)
- new TypeConstraint(body, Tuples.flatTupleOf(var_element2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "NamedElement")));
- PVariable var__virtual_5_ = body.getOrCreateVariableByName(".virtual{5}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_element2, var__virtual_5_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Element", "appliedStereotypeInstance")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_5_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "InstanceSpecification")));
- PVariable var__virtual_6_ = body.getOrCreateVariableByName(".virtual{6}");
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_5_, var__virtual_6_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "InstanceSpecification", "slot")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_6_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Slot")));
- new Equality(body, var__virtual_6_, var_slot2);
- // Slot.definingFeature(slot2, property)
- new TypeConstraint(body, Tuples.flatTupleOf(var_slot2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Slot")));
- PVariable var__virtual_7_ = body.getOrCreateVariableByName(".virtual{7}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_slot2, var__virtual_7_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Slot", "definingFeature")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_7_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "StructuralFeature")));
- new Equality(body, var__virtual_7_, var_property);
- // Slot.value(slot, spec1)
- new TypeConstraint(body, Tuples.flatTupleOf(var_slot), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Slot")));
- PVariable var__virtual_8_ = body.getOrCreateVariableByName(".virtual{8}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_slot, var__virtual_8_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Slot", "value")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_8_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "ValueSpecification")));
- new Equality(body, var__virtual_8_, var_spec1);
- // Slot.value(slot2, spec2)
- new TypeConstraint(body, Tuples.flatTupleOf(var_slot2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Slot")));
- PVariable var__virtual_9_ = body.getOrCreateVariableByName(".virtual{9}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_slot2, var__virtual_9_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Slot", "value")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_9_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "ValueSpecification")));
- new Equality(body, var__virtual_9_, var_spec2);
- // LiteralString.value(spec1, val1)
- new TypeConstraint(body, Tuples.flatTupleOf(var_spec1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "LiteralString")));
- PVariable var__virtual_10_ = body.getOrCreateVariableByName(".virtual{10}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_spec1, var__virtual_10_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "LiteralString", "value")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_10_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "String")));
- new Equality(body, var__virtual_10_, var_val1);
- // LiteralString.value(spec2, val2)
- new TypeConstraint(body, Tuples.flatTupleOf(var_spec2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "LiteralString")));
- PVariable var__virtual_11_ = body.getOrCreateVariableByName(".virtual{11}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_spec2, var__virtual_11_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "LiteralString", "value")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_11_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "String")));
- new Equality(body, var__virtual_11_, var_val2);
- // val1 == val2
- new Equality(body, var_val1, var_val2);
- bodies.add(body);
- }
- return bodies;
- }
- }
-
- private static boolean evaluateExpression_1_1() {
- return true;
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ReachableFromInitState.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ReachableFromInitState.java
deleted file mode 100644
index 4c23dbe..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ReachableFromInitState.java
+++ /dev/null
@@ -1,552 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Unreachable_States.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.incquerylabs.v4md.test.queries.ReachableState;
-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.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.BinaryTransitiveClosure;
-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:
- *
- * pattern reachableFromInitState(state :State){
- * Pseudostate.kind(initnode, ::initial);
- * find reachableState+(initnode, state);
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class ReachableFromInitState extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.reachableFromInitState 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) {
- if ("state".equals(parameterName)) return this.fState;
- 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.v4md.test.queries.reachableFromInitState";
- }
-
- @Override
- public List parameterNames() {
- return ReachableFromInitState.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fState};
- }
-
- @Override
- public ReachableFromInitState.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 ReachableFromInitState.Match)) {
- ReachableFromInitState.Match other = (ReachableFromInitState.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 ReachableFromInitState specification() {
- return ReachableFromInitState.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 ReachableFromInitState.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 ReachableFromInitState.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 ReachableFromInitState.Match newMatch(final State pState) {
- return new Immutable(pState);
- }
-
- private static final class Mutable extends ReachableFromInitState.Match {
- Mutable(final State pState) {
- super(pState);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends ReachableFromInitState.Match {
- Immutable(final State pState) {
- super(pState);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.reachableFromInitState 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 reachableFromInitState(state :State){
- * Pseudostate.kind(initnode, ::initial);
- * find reachableState+(initnode, state);
- * }
- *
- *
- * @see Match
- * @see ReachableFromInitState
- *
- */
- 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 ReachableFromInitState.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 ReachableFromInitState.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_STATE = 0;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ReachableFromInitState.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 ReachableFromInitState.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 ReachableFromInitState.Match newMatch(final State pState) {
- return ReachableFromInitState.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 ReachableFromInitState.Match tupleToMatch(final Tuple t) {
- try {
- return ReachableFromInitState.Match.newMatch((State) t.get(POSITION_STATE));
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in tuple not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ReachableFromInitState.Match arrayToMatch(final Object[] match) {
- try {
- return ReachableFromInitState.Match.newMatch((State) match[POSITION_STATE]);
- } catch(ClassCastException e) {
- LOGGER.error("Element(s) in array not properly typed!",e);
- return null;
- }
- }
-
- @Override
- protected ReachableFromInitState.Match arrayToMatchMutable(final Object[] match) {
- try {
- return ReachableFromInitState.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 ReachableFromInitState.instance();
- }
- }
-
- private ReachableFromInitState() {
- super(GeneratedPQuery.INSTANCE);
- }
-
- /**
- * @return the singleton instance of the query specification
- * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
- *
- */
- public static ReachableFromInitState instance() {
- try{
- return LazyHolder.INSTANCE;
- } catch (ExceptionInInitializerError err) {
- throw processInitializerError(err);
- }
- }
-
- @Override
- protected ReachableFromInitState.Matcher instantiate(final ViatraQueryEngine engine) {
- return ReachableFromInitState.Matcher.on(engine);
- }
-
- @Override
- public ReachableFromInitState.Matcher instantiate() {
- return ReachableFromInitState.Matcher.create();
- }
-
- @Override
- public ReachableFromInitState.Match newEmptyMatch() {
- return ReachableFromInitState.Match.newEmptyMatch();
- }
-
- @Override
- public ReachableFromInitState.Match newMatch(final Object... parameters) {
- return ReachableFromInitState.Match.newMatch((com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.State) parameters[0]);
- }
-
- /**
- * Inner class allowing the singleton instance of {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ReachableFromInitState (visibility: PUBLIC, simpleName: ReachableFromInitState, identifier: com.incquerylabs.v4md.test.queries.ReachableFromInitState, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
- * not at the class load time of the outer class,
- * but rather at the first call to {@link JvmGenericType: com.incquerylabs.v4md.test.queries.ReachableFromInitState (visibility: PUBLIC, simpleName: ReachableFromInitState, identifier: com.incquerylabs.v4md.test.queries.ReachableFromInitState, deprecated: ) (abstract: false, static: false, final: true, packageName: com.incquerylabs.v4md.test.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
- *
- * This workaround is required e.g. to support recursion.
- *
- */
- private static class LazyHolder {
- private final static ReachableFromInitState INSTANCE = new ReachableFromInitState();
-
- /**
- * 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 final static Object STATIC_INITIALIZER = ensureInitialized();
-
- public static Object ensureInitialized() {
- INSTANCE.ensureInitializedInternal();
- return null;
- }
- }
-
- private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
- private final static ReachableFromInitState.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.v4md.test.queries.reachableFromInitState";
- }
-
- @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_initnode = body.getOrCreateVariableByName("initnode");
- 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)
- ));
- // Pseudostate.kind(initnode, ::initial)
- PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
- new ConstantValue(body, var__virtual_0_, com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.PseudostateKindEnum.get("initial"));
- new TypeConstraint(body, Tuples.flatTupleOf(var_initnode), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Pseudostate")));
- PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
- new TypeConstraint(body, Tuples.flatTupleOf(var_initnode, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "Pseudostate", "kind")));
- new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.nomagic.com/magicdraw/UML/2.5.1", "PseudostateKind")));
- new Equality(body, var__virtual_1_, var__virtual_0_);
- // find reachableState+(initnode, state)
- new BinaryTransitiveClosure(body, Tuples.flatTupleOf(var_initnode, var_state), ReachableState.instance().getInternalQueryRepresentation());
- bodies.add(body);
- }
- return bodies;
- }
- }
-}
diff --git a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ReachableState.java b/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ReachableState.java
deleted file mode 100644
index 993888b..0000000
--- a/com.incquerylabs.v4md.snapshotmaker/src/generated/vql/com/incquerylabs/v4md/test/queries/ReachableState.java
+++ /dev/null
@@ -1,711 +0,0 @@
-/**
- * Generated from platform:/resource/com.incquerylabs.v4md.snapshotmaker/src/main/java/com/incquerylabs/v4md/test/queries/Unreachable_States.vql
- */
-package com.incquerylabs.v4md.test.queries;
-
-import com.nomagic.uml2.ext.magicdraw.statemachines.mdbehaviorstatemachines.Vertex;
-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.basicdeferred.Inequality;
-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 reachableState(sourceState : Vertex, targetState : Vertex) {
- * Transition.source(transition, sourceState);
- * Transition.target(transition, targetState);
- * sourceState != targetState;
- *
- *
- * }
- *
- *
- * @see Matcher
- * @see Match
- *
- */
-@SuppressWarnings("all")
-public final class ReachableState extends BaseGeneratedEMFQuerySpecification {
- /**
- * Pattern-specific match representation of the com.incquerylabs.v4md.test.queries.reachableState 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 Vertex fSourceState;
-
- private Vertex fTargetState;
-
- private static List parameterNames = makeImmutableList("sourceState", "targetState");
-
- private Match(final Vertex pSourceState, final Vertex pTargetState) {
- this.fSourceState = pSourceState;
- this.fTargetState = pTargetState;
- }
-
- @Override
- public Object get(final String parameterName) {
- if ("sourceState".equals(parameterName)) return this.fSourceState;
- if ("targetState".equals(parameterName)) return this.fTargetState;
- return null;
- }
-
- public Vertex getSourceState() {
- return this.fSourceState;
- }
-
- public Vertex getTargetState() {
- return this.fTargetState;
- }
-
- @Override
- public boolean set(final String parameterName, final Object newValue) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- if ("sourceState".equals(parameterName) ) {
- this.fSourceState = (Vertex) newValue;
- return true;
- }
- if ("targetState".equals(parameterName) ) {
- this.fTargetState = (Vertex) newValue;
- return true;
- }
- return false;
- }
-
- public void setSourceState(final Vertex pSourceState) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fSourceState = pSourceState;
- }
-
- public void setTargetState(final Vertex pTargetState) {
- if (!isMutable()) throw new java.lang.UnsupportedOperationException();
- this.fTargetState = pTargetState;
- }
-
- @Override
- public String patternName() {
- return "com.incquerylabs.v4md.test.queries.reachableState";
- }
-
- @Override
- public List parameterNames() {
- return ReachableState.Match.parameterNames;
- }
-
- @Override
- public Object[] toArray() {
- return new Object[]{fSourceState, fTargetState};
- }
-
- @Override
- public ReachableState.Match toImmutable() {
- return isMutable() ? newMatch(fSourceState, fTargetState) : this;
- }
-
- @Override
- public String prettyPrint() {
- StringBuilder result = new StringBuilder();
- result.append("\"sourceState\"=" + prettyPrintValue(fSourceState) + ", ");
- result.append("\"targetState\"=" + prettyPrintValue(fTargetState));
- return result.toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(fSourceState, fTargetState);
- }
-
- @Override
- public boolean equals(final Object obj) {
- if (this == obj)
- return true;
- if (obj == null) {
- return false;
- }
- if ((obj instanceof ReachableState.Match)) {
- ReachableState.Match other = (ReachableState.Match) obj;
- return Objects.equals(fSourceState, other.fSourceState) && 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 ReachableState specification() {
- return ReachableState.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 ReachableState.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 pSourceState the fixed value of pattern parameter sourceState, 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 ReachableState.Match newMutableMatch(final Vertex pSourceState, final Vertex pTargetState) {
- return new Mutable(pSourceState, 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 pSourceState the fixed value of pattern parameter sourceState, 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 ReachableState.Match newMatch(final Vertex pSourceState, final Vertex pTargetState) {
- return new Immutable(pSourceState, pTargetState);
- }
-
- private static final class Mutable extends ReachableState.Match {
- Mutable(final Vertex pSourceState, final Vertex pTargetState) {
- super(pSourceState, pTargetState);
- }
-
- @Override
- public boolean isMutable() {
- return true;
- }
- }
-
- private static final class Immutable extends ReachableState.Match {
- Immutable(final Vertex pSourceState, final Vertex pTargetState) {
- super(pSourceState, pTargetState);
- }
-
- @Override
- public boolean isMutable() {
- return false;
- }
- }
- }
-
- /**
- * Generated pattern matcher API of the com.incquerylabs.v4md.test.queries.reachableState 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 reachableState(sourceState : Vertex, targetState : Vertex) {
- * Transition.source(transition, sourceState);
- * Transition.target(transition, targetState);
- * sourceState != targetState;
- *
- *
- * }
- *
- *
- * @see Match
- * @see ReachableState
- *
- */
- 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 ReachableState.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 ReachableState.Matcher create() {
- return new Matcher();
- }
-
- private final static int POSITION_SOURCESTATE = 0;
-
- private final static int POSITION_TARGETSTATE = 1;
-
- private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ReachableState.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 pSourceState the fixed value of pattern parameter sourceState, 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 Vertex pSourceState, final Vertex pTargetState) {
- return rawStreamAllMatches(new Object[]{pSourceState, 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 pSourceState the fixed value of pattern parameter sourceState, 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 Vertex pSourceState, final Vertex pTargetState) {
- return rawStreamAllMatches(new Object[]{pSourceState, 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 pSourceState the fixed value of pattern parameter sourceState, 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 Vertex pSourceState, final Vertex pTargetState) {
- return rawGetOneArbitraryMatch(new Object[]{pSourceState, 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 pSourceState the fixed value of pattern parameter sourceState, 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 Vertex pSourceState, final Vertex pTargetState) {
- return rawHasMatch(new Object[]{pSourceState, pTargetState});
- }
-
- /**
- * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
- * @param pSourceState the fixed value of pattern parameter sourceState, 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 Vertex pSourceState, final Vertex pTargetState) {
- return rawCountMatches(new Object[]{pSourceState, 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 pSourceState the fixed value of pattern parameter sourceState, 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 Vertex pSourceState, final Vertex pTargetState, final Consumer super ReachableState.Match> processor) {
- return rawForOneArbitraryMatch(new Object[]{pSourceState, 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 pSourceState the fixed value of pattern parameter sourceState, 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 ReachableState.Match newMatch(final Vertex pSourceState, final Vertex pTargetState) {
- return ReachableState.Match.newMatch(pSourceState, pTargetState);
- }
-
- /**
- * Retrieve the set of values that occur in matches for sourceState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- protected Stream rawStreamAllValuesOfsourceState(final Object[] parameters) {
- return rawStreamAllValues(POSITION_SOURCESTATE, parameters).map(Vertex.class::cast);
- }
-
- /**
- * Retrieve the set of values that occur in matches for sourceState.
- * @return the Set of all values or empty set if there are no matches
- *
- */
- public Set