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