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