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