/**
* Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.satellite/src/hu/bme/mit/inf/dslreasoner/domains/satellite/queries/SatelliteQueries.vql
*/
package hu.bme.mit.inf.dslreasoner.domains.satellite.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.emf.ecore.EDataType;
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.EDataTypeInSlotsKey;
import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.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.Tuples;
/**
* A pattern-specific query specification that can instantiate GenericPatternMatcher in a type-safe way.
*
*
Original source:
*
* private pattern basePrice(Spacecraft : Spacecraft, BasePrice : java Double) {
* Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat3U);
* BasePrice == 250000.0;
* } or {
* Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat6U);
* BasePrice == 750000.0;
* } or {
* Spacecraft.kind(Spacecraft, SpacecraftKind::SmallSat);
* BasePrice == 3000000.0;
* }
*
*
* @see GenericPatternMatcher
* @see GenericPatternMatch
*
*/
@SuppressWarnings("all")
public final class BasePrice extends BaseGeneratedEMFQuerySpecificationWithGenericMatcher {
private BasePrice() {
super(GeneratedPQuery.INSTANCE);
}
/**
* @return the singleton instance of the query specification
* @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
*
*/
public static BasePrice instance() {
try{
return LazyHolder.INSTANCE;
} catch (ExceptionInInitializerError err) {
throw processInitializerError(err);
}
}
/**
* Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice (visibility: PUBLIC, simpleName: BasePrice, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.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: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice (visibility: PUBLIC, simpleName: BasePrice, identifier: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal.BasePrice, deprecated: ) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.satellite.queries.internal) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
*
* This workaround is required e.g. to support recursion.
*
*/
private static class LazyHolder {
private static final BasePrice INSTANCE = new BasePrice();
/**
* Statically initializes the query specification after the field {@link #INSTANCE} is assigned.
* This initialization order is required to support indirect recursion.
*
*
The static initializer is defined using a helper field to work around limitations of the code generator.
*
*/
private static final Object STATIC_INITIALIZER = ensureInitialized();
public static Object ensureInitialized() {
INSTANCE.ensureInitializedInternal();
return null;
}
}
private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
private static final BasePrice.GeneratedPQuery INSTANCE = new GeneratedPQuery();
private final PParameter parameter_Spacecraft = new PParameter("Spacecraft", "hu.bme.mit.inf.dslreasoner.domains.satellite.Spacecraft", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/satellite", "Spacecraft")), PParameterDirection.INOUT);
private final PParameter parameter_BasePrice = new PParameter("BasePrice", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT);
private final List parameters = Arrays.asList(parameter_Spacecraft, parameter_BasePrice);
private GeneratedPQuery() {
super(PVisibility.PRIVATE);
}
@Override
public String getFullyQualifiedName() {
return "hu.bme.mit.inf.dslreasoner.domains.satellite.queries.basePrice";
}
@Override
public List getParameterNames() {
return Arrays.asList("Spacecraft","BasePrice");
}
@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_Spacecraft = body.getOrCreateVariableByName("Spacecraft");
PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice");
new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft")));
new TypeFilterConstraint(body, Tuples.flatTupleOf(var_BasePrice), new JavaTransitiveInstancesKey(java.lang.Double.class));
body.setSymbolicParameters(Arrays.asList(
new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft),
new ExportedParameter(body, var_BasePrice, parameter_BasePrice)
));
// Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat3U)
PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "CubeSat3U").getInstance());
new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft")));
PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind")));
new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind")));
new Equality(body, var__virtual_1_, var__virtual_0_);
// BasePrice == 250000.0
PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
new ConstantValue(body, var__virtual_2_, 250000.0);
new Equality(body, var_BasePrice, var__virtual_2_);
bodies.add(body);
}
{
PBody body = new PBody(this);
PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft");
PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice");
new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft")));
new TypeFilterConstraint(body, Tuples.flatTupleOf(var_BasePrice), new JavaTransitiveInstancesKey(java.lang.Double.class));
body.setSymbolicParameters(Arrays.asList(
new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft),
new ExportedParameter(body, var_BasePrice, parameter_BasePrice)
));
// Spacecraft.kind(Spacecraft, SpacecraftKind::CubeSat6U)
PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "CubeSat6U").getInstance());
new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft")));
PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind")));
new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind")));
new Equality(body, var__virtual_1_, var__virtual_0_);
// BasePrice == 750000.0
PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
new ConstantValue(body, var__virtual_2_, 750000.0);
new Equality(body, var_BasePrice, var__virtual_2_);
bodies.add(body);
}
{
PBody body = new PBody(this);
PVariable var_Spacecraft = body.getOrCreateVariableByName("Spacecraft");
PVariable var_BasePrice = body.getOrCreateVariableByName("BasePrice");
new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft")));
new TypeFilterConstraint(body, Tuples.flatTupleOf(var_BasePrice), new JavaTransitiveInstancesKey(java.lang.Double.class));
body.setSymbolicParameters(Arrays.asList(
new ExportedParameter(body, var_Spacecraft, parameter_Spacecraft),
new ExportedParameter(body, var_BasePrice, parameter_BasePrice)
));
// Spacecraft.kind(Spacecraft, SpacecraftKind::SmallSat)
PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
new ConstantValue(body, var__virtual_0_, getEnumLiteral("http://www.example.org/satellite", "SpacecraftKind", "SmallSat").getInstance());
new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/satellite", "Spacecraft")));
PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
new TypeConstraint(body, Tuples.flatTupleOf(var_Spacecraft, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/satellite", "Spacecraft", "kind")));
new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.example.org/satellite", "SpacecraftKind")));
new Equality(body, var__virtual_1_, var__virtual_0_);
// BasePrice == 3000000.0
PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
new ConstantValue(body, var__virtual_2_, 3000000.0);
new Equality(body, var_BasePrice, var__virtual_2_);
bodies.add(body);
}
return bodies;
}
}
private static double evaluateExpression_1_1() {
return 250000.0;
}
private static double evaluateExpression_2_1() {
return 750000.0;
}
private static double evaluateExpression_3_1() {
return 3000000.0;
}
}