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