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