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