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