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