aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/X_inv11_incNotOver100.java
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/X_inv11_incNotOver100.java')
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/X_inv11_incNotOver100.java684
1 files changed, 0 insertions, 684 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/X_inv11_incNotOver100.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/X_inv11_incNotOver100.java
deleted file mode 100644
index 995946eb..00000000
--- a/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/X_inv11_incNotOver100.java
+++ /dev/null
@@ -1,684 +0,0 @@
1/**
2 * Generated from platform:/resource/case.study.pledge.run/src/queries/case_study_A.vql
3 */
4package queries;
5
6import Taxation.Expense;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.emf.ecore.EClass;
19import org.eclipse.emf.ecore.EDataType;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
29import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
30import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
31import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
32import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
33import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
34import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
44import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
45
46/**
47 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
48 *
49 * <p>Original source:
50 * <code><pre>
51 * pattern x_inv11_incNotOver100(exp : Expense) {
52 * Expense.income.income_amount(exp, incVal);
53 * check(incVal / 2 {@literal <}= 50);
54 * } or {
55 * Expense.declared_amount(exp, decl);
56 * check(decl {@literal <} 50);
57 * } or {
58 * Expense.income.income_amount(exp, incVal);
59 * Expense.declared_amount(exp, decl);
60 * check(decl {@literal >} incVal/2);
61 * }
62 * </pre></code>
63 *
64 * @see Matcher
65 * @see Match
66 *
67 */
68@SuppressWarnings("all")
69public final class X_inv11_incNotOver100 extends BaseGeneratedEMFQuerySpecification<X_inv11_incNotOver100.Matcher> {
70 /**
71 * Pattern-specific match representation of the queries.x_inv11_incNotOver100 pattern,
72 * to be used in conjunction with {@link Matcher}.
73 *
74 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
75 * Each instance is a (possibly partial) substitution of pattern parameters,
76 * usable to represent a match of the pattern in the result of a query,
77 * or to specify the bound (fixed) input parameters when issuing a query.
78 *
79 * @see Matcher
80 *
81 */
82 public static abstract class Match extends BasePatternMatch {
83 private Expense fExp;
84
85 private static List<String> parameterNames = makeImmutableList("exp");
86
87 private Match(final Expense pExp) {
88 this.fExp = pExp;
89 }
90
91 @Override
92 public Object get(final String parameterName) {
93 switch(parameterName) {
94 case "exp": return this.fExp;
95 default: return null;
96 }
97 }
98
99 @Override
100 public Object get(final int index) {
101 switch(index) {
102 case 0: return this.fExp;
103 default: return null;
104 }
105 }
106
107 public Expense getExp() {
108 return this.fExp;
109 }
110
111 @Override
112 public boolean set(final String parameterName, final Object newValue) {
113 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
114 if ("exp".equals(parameterName) ) {
115 this.fExp = (Expense) newValue;
116 return true;
117 }
118 return false;
119 }
120
121 public void setExp(final Expense pExp) {
122 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
123 this.fExp = pExp;
124 }
125
126 @Override
127 public String patternName() {
128 return "queries.x_inv11_incNotOver100";
129 }
130
131 @Override
132 public List<String> parameterNames() {
133 return X_inv11_incNotOver100.Match.parameterNames;
134 }
135
136 @Override
137 public Object[] toArray() {
138 return new Object[]{fExp};
139 }
140
141 @Override
142 public X_inv11_incNotOver100.Match toImmutable() {
143 return isMutable() ? newMatch(fExp) : this;
144 }
145
146 @Override
147 public String prettyPrint() {
148 StringBuilder result = new StringBuilder();
149 result.append("\"exp\"=" + prettyPrintValue(fExp));
150 return result.toString();
151 }
152
153 @Override
154 public int hashCode() {
155 return Objects.hash(fExp);
156 }
157
158 @Override
159 public boolean equals(final Object obj) {
160 if (this == obj)
161 return true;
162 if (obj == null) {
163 return false;
164 }
165 if ((obj instanceof X_inv11_incNotOver100.Match)) {
166 X_inv11_incNotOver100.Match other = (X_inv11_incNotOver100.Match) obj;
167 return Objects.equals(fExp, other.fExp);
168 } else {
169 // this should be infrequent
170 if (!(obj instanceof IPatternMatch)) {
171 return false;
172 }
173 IPatternMatch otherSig = (IPatternMatch) obj;
174 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
175 }
176 }
177
178 @Override
179 public X_inv11_incNotOver100 specification() {
180 return X_inv11_incNotOver100.instance();
181 }
182
183 /**
184 * Returns an empty, mutable match.
185 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
186 *
187 * @return the empty match.
188 *
189 */
190 public static X_inv11_incNotOver100.Match newEmptyMatch() {
191 return new Mutable(null);
192 }
193
194 /**
195 * Returns a mutable (partial) match.
196 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
197 *
198 * @param pExp the fixed value of pattern parameter exp, or null if not bound.
199 * @return the new, mutable (partial) match object.
200 *
201 */
202 public static X_inv11_incNotOver100.Match newMutableMatch(final Expense pExp) {
203 return new Mutable(pExp);
204 }
205
206 /**
207 * Returns a new (partial) match.
208 * This can be used e.g. to call the matcher with a partial match.
209 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
210 * @param pExp the fixed value of pattern parameter exp, or null if not bound.
211 * @return the (partial) match object.
212 *
213 */
214 public static X_inv11_incNotOver100.Match newMatch(final Expense pExp) {
215 return new Immutable(pExp);
216 }
217
218 private static final class Mutable extends X_inv11_incNotOver100.Match {
219 Mutable(final Expense pExp) {
220 super(pExp);
221 }
222
223 @Override
224 public boolean isMutable() {
225 return true;
226 }
227 }
228
229 private static final class Immutable extends X_inv11_incNotOver100.Match {
230 Immutable(final Expense pExp) {
231 super(pExp);
232 }
233
234 @Override
235 public boolean isMutable() {
236 return false;
237 }
238 }
239 }
240
241 /**
242 * Generated pattern matcher API of the queries.x_inv11_incNotOver100 pattern,
243 * providing pattern-specific query methods.
244 *
245 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
246 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
247 *
248 * <p>Matches of the pattern will be represented as {@link Match}.
249 *
250 * <p>Original source:
251 * <code><pre>
252 * pattern x_inv11_incNotOver100(exp : Expense) {
253 * Expense.income.income_amount(exp, incVal);
254 * check(incVal / 2 {@literal <}= 50);
255 * } or {
256 * Expense.declared_amount(exp, decl);
257 * check(decl {@literal <} 50);
258 * } or {
259 * Expense.income.income_amount(exp, incVal);
260 * Expense.declared_amount(exp, decl);
261 * check(decl {@literal >} incVal/2);
262 * }
263 * </pre></code>
264 *
265 * @see Match
266 * @see X_inv11_incNotOver100
267 *
268 */
269 public static class Matcher extends BaseMatcher<X_inv11_incNotOver100.Match> {
270 /**
271 * Initializes the pattern matcher within an existing VIATRA Query engine.
272 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
273 *
274 * @param engine the existing VIATRA Query engine in which this matcher will be created.
275 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
276 *
277 */
278 public static X_inv11_incNotOver100.Matcher on(final ViatraQueryEngine engine) {
279 // check if matcher already exists
280 Matcher matcher = engine.getExistingMatcher(querySpecification());
281 if (matcher == null) {
282 matcher = (Matcher)engine.getMatcher(querySpecification());
283 }
284 return matcher;
285 }
286
287 /**
288 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
289 * @return an initialized matcher
290 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
291 *
292 */
293 public static X_inv11_incNotOver100.Matcher create() {
294 return new Matcher();
295 }
296
297 private static final int POSITION_EXP = 0;
298
299 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(X_inv11_incNotOver100.Matcher.class);
300
301 /**
302 * Initializes the pattern matcher within an existing VIATRA Query engine.
303 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
304 *
305 * @param engine the existing VIATRA Query engine in which this matcher will be created.
306 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
307 *
308 */
309 private Matcher() {
310 super(querySpecification());
311 }
312
313 /**
314 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
315 * @param pExp the fixed value of pattern parameter exp, or null if not bound.
316 * @return matches represented as a Match object.
317 *
318 */
319 public Collection<X_inv11_incNotOver100.Match> getAllMatches(final Expense pExp) {
320 return rawStreamAllMatches(new Object[]{pExp}).collect(Collectors.toSet());
321 }
322
323 /**
324 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
325 * </p>
326 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
327 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
328 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
329 * @param pExp the fixed value of pattern parameter exp, or null if not bound.
330 * @return a stream of matches represented as a Match object.
331 *
332 */
333 public Stream<X_inv11_incNotOver100.Match> streamAllMatches(final Expense pExp) {
334 return rawStreamAllMatches(new Object[]{pExp});
335 }
336
337 /**
338 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
339 * Neither determinism nor randomness of selection is guaranteed.
340 * @param pExp the fixed value of pattern parameter exp, or null if not bound.
341 * @return a match represented as a Match object, or null if no match is found.
342 *
343 */
344 public Optional<X_inv11_incNotOver100.Match> getOneArbitraryMatch(final Expense pExp) {
345 return rawGetOneArbitraryMatch(new Object[]{pExp});
346 }
347
348 /**
349 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
350 * under any possible substitution of the unspecified parameters (if any).
351 * @param pExp the fixed value of pattern parameter exp, or null if not bound.
352 * @return true if the input is a valid (partial) match of the pattern.
353 *
354 */
355 public boolean hasMatch(final Expense pExp) {
356 return rawHasMatch(new Object[]{pExp});
357 }
358
359 /**
360 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
361 * @param pExp the fixed value of pattern parameter exp, or null if not bound.
362 * @return the number of pattern matches found.
363 *
364 */
365 public int countMatches(final Expense pExp) {
366 return rawCountMatches(new Object[]{pExp});
367 }
368
369 /**
370 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
371 * Neither determinism nor randomness of selection is guaranteed.
372 * @param pExp the fixed value of pattern parameter exp, or null if not bound.
373 * @param processor the action that will process the selected match.
374 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
375 *
376 */
377 public boolean forOneArbitraryMatch(final Expense pExp, final Consumer<? super X_inv11_incNotOver100.Match> processor) {
378 return rawForOneArbitraryMatch(new Object[]{pExp}, processor);
379 }
380
381 /**
382 * Returns a new (partial) match.
383 * This can be used e.g. to call the matcher with a partial match.
384 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
385 * @param pExp the fixed value of pattern parameter exp, or null if not bound.
386 * @return the (partial) match object.
387 *
388 */
389 public X_inv11_incNotOver100.Match newMatch(final Expense pExp) {
390 return X_inv11_incNotOver100.Match.newMatch(pExp);
391 }
392
393 /**
394 * Retrieve the set of values that occur in matches for exp.
395 * @return the Set of all values or empty set if there are no matches
396 *
397 */
398 protected Stream<Expense> rawStreamAllValuesOfexp(final Object[] parameters) {
399 return rawStreamAllValues(POSITION_EXP, parameters).map(Expense.class::cast);
400 }
401
402 /**
403 * Retrieve the set of values that occur in matches for exp.
404 * @return the Set of all values or empty set if there are no matches
405 *
406 */
407 public Set<Expense> getAllValuesOfexp() {
408 return rawStreamAllValuesOfexp(emptyArray()).collect(Collectors.toSet());
409 }
410
411 /**
412 * Retrieve the set of values that occur in matches for exp.
413 * @return the Set of all values or empty set if there are no matches
414 *
415 */
416 public Stream<Expense> streamAllValuesOfexp() {
417 return rawStreamAllValuesOfexp(emptyArray());
418 }
419
420 @Override
421 protected X_inv11_incNotOver100.Match tupleToMatch(final Tuple t) {
422 try {
423 return X_inv11_incNotOver100.Match.newMatch((Expense) t.get(POSITION_EXP));
424 } catch(ClassCastException e) {
425 LOGGER.error("Element(s) in tuple not properly typed!",e);
426 return null;
427 }
428 }
429
430 @Override
431 protected X_inv11_incNotOver100.Match arrayToMatch(final Object[] match) {
432 try {
433 return X_inv11_incNotOver100.Match.newMatch((Expense) match[POSITION_EXP]);
434 } catch(ClassCastException e) {
435 LOGGER.error("Element(s) in array not properly typed!",e);
436 return null;
437 }
438 }
439
440 @Override
441 protected X_inv11_incNotOver100.Match arrayToMatchMutable(final Object[] match) {
442 try {
443 return X_inv11_incNotOver100.Match.newMutableMatch((Expense) match[POSITION_EXP]);
444 } catch(ClassCastException e) {
445 LOGGER.error("Element(s) in array not properly typed!",e);
446 return null;
447 }
448 }
449
450 /**
451 * @return the singleton instance of the query specification of this pattern
452 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
453 *
454 */
455 public static IQuerySpecification<X_inv11_incNotOver100.Matcher> querySpecification() {
456 return X_inv11_incNotOver100.instance();
457 }
458 }
459
460 private X_inv11_incNotOver100() {
461 super(GeneratedPQuery.INSTANCE);
462 }
463
464 /**
465 * @return the singleton instance of the query specification
466 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
467 *
468 */
469 public static X_inv11_incNotOver100 instance() {
470 try{
471 return LazyHolder.INSTANCE;
472 } catch (ExceptionInInitializerError err) {
473 throw processInitializerError(err);
474 }
475 }
476
477 @Override
478 protected X_inv11_incNotOver100.Matcher instantiate(final ViatraQueryEngine engine) {
479 return X_inv11_incNotOver100.Matcher.on(engine);
480 }
481
482 @Override
483 public X_inv11_incNotOver100.Matcher instantiate() {
484 return X_inv11_incNotOver100.Matcher.create();
485 }
486
487 @Override
488 public X_inv11_incNotOver100.Match newEmptyMatch() {
489 return X_inv11_incNotOver100.Match.newEmptyMatch();
490 }
491
492 @Override
493 public X_inv11_incNotOver100.Match newMatch(final Object... parameters) {
494 return X_inv11_incNotOver100.Match.newMatch((Taxation.Expense) parameters[0]);
495 }
496
497 /**
498 * Inner class allowing the singleton instance of {@link X_inv11_incNotOver100} to be created
499 * <b>not</b> at the class load time of the outer class,
500 * but rather at the first call to {@link X_inv11_incNotOver100#instance()}.
501 *
502 * <p> This workaround is required e.g. to support recursion.
503 *
504 */
505 private static class LazyHolder {
506 private static final X_inv11_incNotOver100 INSTANCE = new X_inv11_incNotOver100();
507
508 /**
509 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
510 * This initialization order is required to support indirect recursion.
511 *
512 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
513 *
514 */
515 private static final Object STATIC_INITIALIZER = ensureInitialized();
516
517 public static Object ensureInitialized() {
518 INSTANCE.ensureInitializedInternal();
519 return null;
520 }
521 }
522
523 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
524 private static final X_inv11_incNotOver100.GeneratedPQuery INSTANCE = new GeneratedPQuery();
525
526 private final PParameter parameter_exp = new PParameter("exp", "Taxation.Expense", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http:///TaxCard.ecore", "Expense")), PParameterDirection.INOUT);
527
528 private final List<PParameter> parameters = Arrays.asList(parameter_exp);
529
530 private GeneratedPQuery() {
531 super(PVisibility.PUBLIC);
532 }
533
534 @Override
535 public String getFullyQualifiedName() {
536 return "queries.x_inv11_incNotOver100";
537 }
538
539 @Override
540 public List<String> getParameterNames() {
541 return Arrays.asList("exp");
542 }
543
544 @Override
545 public List<PParameter> getParameters() {
546 return parameters;
547 }
548
549 @Override
550 public Set<PBody> doGetContainedBodies() {
551 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
552 Set<PBody> bodies = new LinkedHashSet<>();
553 {
554 PBody body = new PBody(this);
555 PVariable var_exp = body.getOrCreateVariableByName("exp");
556 PVariable var_incVal = body.getOrCreateVariableByName("incVal");
557 new TypeConstraint(body, Tuples.flatTupleOf(var_exp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Expense")));
558 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
559 new ExportedParameter(body, var_exp, parameter_exp)
560 ));
561 // Expense.income.income_amount(exp, incVal)
562 new TypeConstraint(body, Tuples.flatTupleOf(var_exp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Expense")));
563 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
564 new TypeConstraint(body, Tuples.flatTupleOf(var_exp, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Expense", "income")));
565 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Income")));
566 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
567 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Income", "income_amount")));
568 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EDouble")));
569 new Equality(body, var__virtual_1_, var_incVal);
570 // check(incVal / 2 <= 50)
571 new ExpressionEvaluation(body, new IExpressionEvaluator() {
572
573 @Override
574 public String getShortDescription() {
575 return "Expression evaluation from pattern x_inv11_incNotOver100";
576 }
577
578 @Override
579 public Iterable<String> getInputParameterNames() {
580 return Arrays.asList("incVal");}
581
582 @Override
583 public Object evaluateExpression(IValueProvider provider) throws Exception {
584 Double incVal = (Double) provider.getValue("incVal");
585 return evaluateExpression_1_1(incVal);
586 }
587 }, null);
588 bodies.add(body);
589 }
590 {
591 PBody body = new PBody(this);
592 PVariable var_exp = body.getOrCreateVariableByName("exp");
593 PVariable var_decl = body.getOrCreateVariableByName("decl");
594 new TypeConstraint(body, Tuples.flatTupleOf(var_exp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Expense")));
595 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
596 new ExportedParameter(body, var_exp, parameter_exp)
597 ));
598 // Expense.declared_amount(exp, decl)
599 new TypeConstraint(body, Tuples.flatTupleOf(var_exp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Expense")));
600 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
601 new TypeConstraint(body, Tuples.flatTupleOf(var_exp, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Expense", "declared_amount")));
602 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EDouble")));
603 new Equality(body, var__virtual_0_, var_decl);
604 // check(decl < 50)
605 new ExpressionEvaluation(body, new IExpressionEvaluator() {
606
607 @Override
608 public String getShortDescription() {
609 return "Expression evaluation from pattern x_inv11_incNotOver100";
610 }
611
612 @Override
613 public Iterable<String> getInputParameterNames() {
614 return Arrays.asList("decl");}
615
616 @Override
617 public Object evaluateExpression(IValueProvider provider) throws Exception {
618 Double decl = (Double) provider.getValue("decl");
619 return evaluateExpression_2_1(decl);
620 }
621 }, null);
622 bodies.add(body);
623 }
624 {
625 PBody body = new PBody(this);
626 PVariable var_exp = body.getOrCreateVariableByName("exp");
627 PVariable var_incVal = body.getOrCreateVariableByName("incVal");
628 PVariable var_decl = body.getOrCreateVariableByName("decl");
629 new TypeConstraint(body, Tuples.flatTupleOf(var_exp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Expense")));
630 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
631 new ExportedParameter(body, var_exp, parameter_exp)
632 ));
633 // Expense.income.income_amount(exp, incVal)
634 new TypeConstraint(body, Tuples.flatTupleOf(var_exp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Expense")));
635 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
636 new TypeConstraint(body, Tuples.flatTupleOf(var_exp, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Expense", "income")));
637 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Income")));
638 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
639 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Income", "income_amount")));
640 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EDouble")));
641 new Equality(body, var__virtual_1_, var_incVal);
642 // Expense.declared_amount(exp, decl)
643 new TypeConstraint(body, Tuples.flatTupleOf(var_exp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Expense")));
644 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
645 new TypeConstraint(body, Tuples.flatTupleOf(var_exp, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Expense", "declared_amount")));
646 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EDouble")));
647 new Equality(body, var__virtual_2_, var_decl);
648 // check(decl > incVal/2)
649 new ExpressionEvaluation(body, new IExpressionEvaluator() {
650
651 @Override
652 public String getShortDescription() {
653 return "Expression evaluation from pattern x_inv11_incNotOver100";
654 }
655
656 @Override
657 public Iterable<String> getInputParameterNames() {
658 return Arrays.asList("decl", "incVal");}
659
660 @Override
661 public Object evaluateExpression(IValueProvider provider) throws Exception {
662 Double decl = (Double) provider.getValue("decl");
663 Double incVal = (Double) provider.getValue("incVal");
664 return evaluateExpression_3_1(decl, incVal);
665 }
666 }, null);
667 bodies.add(body);
668 }
669 return bodies;
670 }
671 }
672
673 private static boolean evaluateExpression_1_1(final Double incVal) {
674 return (((incVal).doubleValue() / 2) <= 50);
675 }
676
677 private static boolean evaluateExpression_2_1(final Double decl) {
678 return ((decl).doubleValue() < 50);
679 }
680
681 private static boolean evaluateExpression_3_1(final Double decl, final Double incVal) {
682 return ((decl).doubleValue() > ((incVal).doubleValue() / 2));
683 }
684}