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