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