diff options
author | ArenBabikian <aren.babikian@mail.mcgill.ca> | 2020-05-10 20:56:55 -0400 |
---|---|---|
committer | ArenBabikian <aren.babikian@mail.mcgill.ca> | 2020-05-10 20:56:55 -0400 |
commit | fb99d0d2a8ddcd7bad3b1f59152328e76ae8edb6 (patch) | |
tree | 4ee9262ebb91eb6bf8a84af0f771d6c4366c7b0d /Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen | |
parent | Satelite case study update for Models-Attribute paper (diff) | |
download | VIATRA-Generator-fb99d0d2a8ddcd7bad3b1f59152328e76ae8edb6.tar.gz VIATRA-Generator-fb99d0d2a8ddcd7bad3b1f59152328e76ae8edb6.tar.zst VIATRA-Generator-fb99d0d2a8ddcd7bad3b1f59152328e76ae8edb6.zip |
Fix PLEDGE Case Study File
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen')
3 files changed, 627 insertions, 0 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen/queries/.gitignore b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen/queries/.gitignore index 527f3a0e..f679c1a8 100644 --- a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen/queries/.gitignore +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen/queries/.gitignore | |||
@@ -110,3 +110,11 @@ | |||
110 | /X_inv48_notDis.java | 110 | /X_inv48_notDis.java |
111 | /X_inv49_1.java | 111 | /X_inv49_1.java |
112 | /X_inv49_2.java | 112 | /X_inv49_2.java |
113 | /.FamilyTreeConstraints.java._trace | ||
114 | /.MemberHasParent.java._trace | ||
115 | /.MemberIsItsOwnParent.java._trace | ||
116 | /.NegativeAge.java._trace | ||
117 | /.ParentTooYoung.java._trace | ||
118 | /.TwoMembersHaveNoParent.java._trace | ||
119 | /.Case_study_short.java._trace | ||
120 | /.X_inv48.java._trace | ||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen/queries/Case_study_short.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen/queries/Case_study_short.java new file mode 100644 index 00000000..5c72b809 --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen/queries/Case_study_short.java | |||
@@ -0,0 +1,64 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/case.study.pledge.run/src/queries/case_study_short.vql | ||
3 | */ | ||
4 | package queries; | ||
5 | |||
6 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
7 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedPatternGroup; | ||
8 | import queries.Inv48; | ||
9 | import queries.X_inv48; | ||
10 | |||
11 | /** | ||
12 | * A pattern group formed of all public patterns defined in case_study_short.vql. | ||
13 | * | ||
14 | * <p>Use the static instance as any {@link interface org.eclipse.viatra.query.runtime.api.IQueryGroup}, to conveniently prepare | ||
15 | * a VIATRA Query engine for matching all patterns originally defined in file case_study_short.vql, | ||
16 | * in order to achieve better performance than one-by-one on-demand matcher initialization. | ||
17 | * | ||
18 | * <p> From package queries, the group contains the definition of the following patterns: <ul> | ||
19 | * <li>inv48</li> | ||
20 | * <li>x_inv48</li> | ||
21 | * </ul> | ||
22 | * | ||
23 | * @see IQueryGroup | ||
24 | * | ||
25 | */ | ||
26 | @SuppressWarnings("all") | ||
27 | public final class Case_study_short extends BaseGeneratedPatternGroup { | ||
28 | /** | ||
29 | * Access the pattern group. | ||
30 | * | ||
31 | * @return the singleton instance of the group | ||
32 | * @throws ViatraQueryRuntimeException if there was an error loading the generated code of pattern specifications | ||
33 | * | ||
34 | */ | ||
35 | public static Case_study_short instance() { | ||
36 | if (INSTANCE == null) { | ||
37 | INSTANCE = new Case_study_short(); | ||
38 | } | ||
39 | return INSTANCE; | ||
40 | } | ||
41 | |||
42 | private static Case_study_short INSTANCE; | ||
43 | |||
44 | private Case_study_short() { | ||
45 | querySpecifications.add(Inv48.instance()); | ||
46 | querySpecifications.add(X_inv48.instance()); | ||
47 | } | ||
48 | |||
49 | public Inv48 getInv48() { | ||
50 | return Inv48.instance(); | ||
51 | } | ||
52 | |||
53 | public Inv48.Matcher getInv48(final ViatraQueryEngine engine) { | ||
54 | return Inv48.Matcher.on(engine); | ||
55 | } | ||
56 | |||
57 | public X_inv48 getX_inv48() { | ||
58 | return X_inv48.instance(); | ||
59 | } | ||
60 | |||
61 | public X_inv48.Matcher getX_inv48(final ViatraQueryEngine engine) { | ||
62 | return X_inv48.Matcher.on(engine); | ||
63 | } | ||
64 | } | ||
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen/queries/X_inv48.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen/queries/X_inv48.java new file mode 100644 index 00000000..b02f3c99 --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.run/src-gen/queries/X_inv48.java | |||
@@ -0,0 +1,555 @@ | |||
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.PBody; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
42 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
43 | |||
44 | /** | ||
45 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
46 | * | ||
47 | * <p>Original source: | ||
48 | * <code><pre> | ||
49 | * pattern x_inv48(p : Physical_Person) { | ||
50 | * Physical_Person.disability_type(p, ::NONE); | ||
51 | * } | ||
52 | * </pre></code> | ||
53 | * | ||
54 | * @see Matcher | ||
55 | * @see Match | ||
56 | * | ||
57 | */ | ||
58 | @SuppressWarnings("all") | ||
59 | public final class X_inv48 extends BaseGeneratedEMFQuerySpecification<X_inv48.Matcher> { | ||
60 | /** | ||
61 | * Pattern-specific match representation of the queries.x_inv48 pattern, | ||
62 | * to be used in conjunction with {@link Matcher}. | ||
63 | * | ||
64 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
65 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
66 | * usable to represent a match of the pattern in the result of a query, | ||
67 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * | ||
71 | */ | ||
72 | public static abstract class Match extends BasePatternMatch { | ||
73 | private Physical_Person fP; | ||
74 | |||
75 | private static List<String> parameterNames = makeImmutableList("p"); | ||
76 | |||
77 | private Match(final Physical_Person pP) { | ||
78 | this.fP = pP; | ||
79 | } | ||
80 | |||
81 | @Override | ||
82 | public Object get(final String parameterName) { | ||
83 | switch(parameterName) { | ||
84 | case "p": return this.fP; | ||
85 | default: return null; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | @Override | ||
90 | public Object get(final int index) { | ||
91 | switch(index) { | ||
92 | case 0: return this.fP; | ||
93 | default: return null; | ||
94 | } | ||
95 | } | ||
96 | |||
97 | public Physical_Person getP() { | ||
98 | return this.fP; | ||
99 | } | ||
100 | |||
101 | @Override | ||
102 | public boolean set(final String parameterName, final Object newValue) { | ||
103 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
104 | if ("p".equals(parameterName) ) { | ||
105 | this.fP = (Physical_Person) newValue; | ||
106 | return true; | ||
107 | } | ||
108 | return false; | ||
109 | } | ||
110 | |||
111 | public void setP(final Physical_Person pP) { | ||
112 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
113 | this.fP = pP; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public String patternName() { | ||
118 | return "queries.x_inv48"; | ||
119 | } | ||
120 | |||
121 | @Override | ||
122 | public List<String> parameterNames() { | ||
123 | return X_inv48.Match.parameterNames; | ||
124 | } | ||
125 | |||
126 | @Override | ||
127 | public Object[] toArray() { | ||
128 | return new Object[]{fP}; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public X_inv48.Match toImmutable() { | ||
133 | return isMutable() ? newMatch(fP) : this; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public String prettyPrint() { | ||
138 | StringBuilder result = new StringBuilder(); | ||
139 | result.append("\"p\"=" + prettyPrintValue(fP)); | ||
140 | return result.toString(); | ||
141 | } | ||
142 | |||
143 | @Override | ||
144 | public int hashCode() { | ||
145 | return Objects.hash(fP); | ||
146 | } | ||
147 | |||
148 | @Override | ||
149 | public boolean equals(final Object obj) { | ||
150 | if (this == obj) | ||
151 | return true; | ||
152 | if (obj == null) { | ||
153 | return false; | ||
154 | } | ||
155 | if ((obj instanceof X_inv48.Match)) { | ||
156 | X_inv48.Match other = (X_inv48.Match) obj; | ||
157 | return Objects.equals(fP, other.fP); | ||
158 | } else { | ||
159 | // this should be infrequent | ||
160 | if (!(obj instanceof IPatternMatch)) { | ||
161 | return false; | ||
162 | } | ||
163 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
164 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | @Override | ||
169 | public X_inv48 specification() { | ||
170 | return X_inv48.instance(); | ||
171 | } | ||
172 | |||
173 | /** | ||
174 | * Returns an empty, mutable match. | ||
175 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
176 | * | ||
177 | * @return the empty match. | ||
178 | * | ||
179 | */ | ||
180 | public static X_inv48.Match newEmptyMatch() { | ||
181 | return new Mutable(null); | ||
182 | } | ||
183 | |||
184 | /** | ||
185 | * Returns a mutable (partial) match. | ||
186 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
187 | * | ||
188 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
189 | * @return the new, mutable (partial) match object. | ||
190 | * | ||
191 | */ | ||
192 | public static X_inv48.Match newMutableMatch(final Physical_Person pP) { | ||
193 | return new Mutable(pP); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns a new (partial) match. | ||
198 | * This can be used e.g. to call the matcher with a partial match. | ||
199 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
200 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
201 | * @return the (partial) match object. | ||
202 | * | ||
203 | */ | ||
204 | public static X_inv48.Match newMatch(final Physical_Person pP) { | ||
205 | return new Immutable(pP); | ||
206 | } | ||
207 | |||
208 | private static final class Mutable extends X_inv48.Match { | ||
209 | Mutable(final Physical_Person pP) { | ||
210 | super(pP); | ||
211 | } | ||
212 | |||
213 | @Override | ||
214 | public boolean isMutable() { | ||
215 | return true; | ||
216 | } | ||
217 | } | ||
218 | |||
219 | private static final class Immutable extends X_inv48.Match { | ||
220 | Immutable(final Physical_Person pP) { | ||
221 | super(pP); | ||
222 | } | ||
223 | |||
224 | @Override | ||
225 | public boolean isMutable() { | ||
226 | return false; | ||
227 | } | ||
228 | } | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Generated pattern matcher API of the queries.x_inv48 pattern, | ||
233 | * providing pattern-specific query methods. | ||
234 | * | ||
235 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
236 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
237 | * | ||
238 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
239 | * | ||
240 | * <p>Original source: | ||
241 | * <code><pre> | ||
242 | * pattern x_inv48(p : Physical_Person) { | ||
243 | * Physical_Person.disability_type(p, ::NONE); | ||
244 | * } | ||
245 | * </pre></code> | ||
246 | * | ||
247 | * @see Match | ||
248 | * @see X_inv48 | ||
249 | * | ||
250 | */ | ||
251 | public static class Matcher extends BaseMatcher<X_inv48.Match> { | ||
252 | /** | ||
253 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
254 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
255 | * | ||
256 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
257 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
258 | * | ||
259 | */ | ||
260 | public static X_inv48.Matcher on(final ViatraQueryEngine engine) { | ||
261 | // check if matcher already exists | ||
262 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
263 | if (matcher == null) { | ||
264 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
265 | } | ||
266 | return matcher; | ||
267 | } | ||
268 | |||
269 | /** | ||
270 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
271 | * @return an initialized matcher | ||
272 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
273 | * | ||
274 | */ | ||
275 | public static X_inv48.Matcher create() { | ||
276 | return new Matcher(); | ||
277 | } | ||
278 | |||
279 | private static final int POSITION_P = 0; | ||
280 | |||
281 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(X_inv48.Matcher.class); | ||
282 | |||
283 | /** | ||
284 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
285 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
286 | * | ||
287 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
288 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
289 | * | ||
290 | */ | ||
291 | private Matcher() { | ||
292 | super(querySpecification()); | ||
293 | } | ||
294 | |||
295 | /** | ||
296 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
297 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
298 | * @return matches represented as a Match object. | ||
299 | * | ||
300 | */ | ||
301 | public Collection<X_inv48.Match> getAllMatches(final Physical_Person pP) { | ||
302 | return rawStreamAllMatches(new Object[]{pP}).collect(Collectors.toSet()); | ||
303 | } | ||
304 | |||
305 | /** | ||
306 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
307 | * </p> | ||
308 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
309 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
310 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
311 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
312 | * @return a stream of matches represented as a Match object. | ||
313 | * | ||
314 | */ | ||
315 | public Stream<X_inv48.Match> streamAllMatches(final Physical_Person pP) { | ||
316 | return rawStreamAllMatches(new Object[]{pP}); | ||
317 | } | ||
318 | |||
319 | /** | ||
320 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
321 | * Neither determinism nor randomness of selection is guaranteed. | ||
322 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
323 | * @return a match represented as a Match object, or null if no match is found. | ||
324 | * | ||
325 | */ | ||
326 | public Optional<X_inv48.Match> getOneArbitraryMatch(final Physical_Person pP) { | ||
327 | return rawGetOneArbitraryMatch(new Object[]{pP}); | ||
328 | } | ||
329 | |||
330 | /** | ||
331 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
332 | * under any possible substitution of the unspecified parameters (if any). | ||
333 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
334 | * @return true if the input is a valid (partial) match of the pattern. | ||
335 | * | ||
336 | */ | ||
337 | public boolean hasMatch(final Physical_Person pP) { | ||
338 | return rawHasMatch(new Object[]{pP}); | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
343 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
344 | * @return the number of pattern matches found. | ||
345 | * | ||
346 | */ | ||
347 | public int countMatches(final Physical_Person pP) { | ||
348 | return rawCountMatches(new Object[]{pP}); | ||
349 | } | ||
350 | |||
351 | /** | ||
352 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
353 | * Neither determinism nor randomness of selection is guaranteed. | ||
354 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
355 | * @param processor the action that will process the selected match. | ||
356 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
357 | * | ||
358 | */ | ||
359 | public boolean forOneArbitraryMatch(final Physical_Person pP, final Consumer<? super X_inv48.Match> processor) { | ||
360 | return rawForOneArbitraryMatch(new Object[]{pP}, processor); | ||
361 | } | ||
362 | |||
363 | /** | ||
364 | * Returns a new (partial) match. | ||
365 | * This can be used e.g. to call the matcher with a partial match. | ||
366 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
367 | * @param pP the fixed value of pattern parameter p, or null if not bound. | ||
368 | * @return the (partial) match object. | ||
369 | * | ||
370 | */ | ||
371 | public X_inv48.Match newMatch(final Physical_Person pP) { | ||
372 | return X_inv48.Match.newMatch(pP); | ||
373 | } | ||
374 | |||
375 | /** | ||
376 | * Retrieve the set of values that occur in matches for p. | ||
377 | * @return the Set of all values or empty set if there are no matches | ||
378 | * | ||
379 | */ | ||
380 | protected Stream<Physical_Person> rawStreamAllValuesOfp(final Object[] parameters) { | ||
381 | return rawStreamAllValues(POSITION_P, parameters).map(Physical_Person.class::cast); | ||
382 | } | ||
383 | |||
384 | /** | ||
385 | * Retrieve the set of values that occur in matches for p. | ||
386 | * @return the Set of all values or empty set if there are no matches | ||
387 | * | ||
388 | */ | ||
389 | public Set<Physical_Person> getAllValuesOfp() { | ||
390 | return rawStreamAllValuesOfp(emptyArray()).collect(Collectors.toSet()); | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * Retrieve the set of values that occur in matches for p. | ||
395 | * @return the Set of all values or empty set if there are no matches | ||
396 | * | ||
397 | */ | ||
398 | public Stream<Physical_Person> streamAllValuesOfp() { | ||
399 | return rawStreamAllValuesOfp(emptyArray()); | ||
400 | } | ||
401 | |||
402 | @Override | ||
403 | protected X_inv48.Match tupleToMatch(final Tuple t) { | ||
404 | try { | ||
405 | return X_inv48.Match.newMatch((Physical_Person) t.get(POSITION_P)); | ||
406 | } catch(ClassCastException e) { | ||
407 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
408 | return null; | ||
409 | } | ||
410 | } | ||
411 | |||
412 | @Override | ||
413 | protected X_inv48.Match arrayToMatch(final Object[] match) { | ||
414 | try { | ||
415 | return X_inv48.Match.newMatch((Physical_Person) match[POSITION_P]); | ||
416 | } catch(ClassCastException e) { | ||
417 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
418 | return null; | ||
419 | } | ||
420 | } | ||
421 | |||
422 | @Override | ||
423 | protected X_inv48.Match arrayToMatchMutable(final Object[] match) { | ||
424 | try { | ||
425 | return X_inv48.Match.newMutableMatch((Physical_Person) match[POSITION_P]); | ||
426 | } catch(ClassCastException e) { | ||
427 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
428 | return null; | ||
429 | } | ||
430 | } | ||
431 | |||
432 | /** | ||
433 | * @return the singleton instance of the query specification of this pattern | ||
434 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
435 | * | ||
436 | */ | ||
437 | public static IQuerySpecification<X_inv48.Matcher> querySpecification() { | ||
438 | return X_inv48.instance(); | ||
439 | } | ||
440 | } | ||
441 | |||
442 | private X_inv48() { | ||
443 | super(GeneratedPQuery.INSTANCE); | ||
444 | } | ||
445 | |||
446 | /** | ||
447 | * @return the singleton instance of the query specification | ||
448 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
449 | * | ||
450 | */ | ||
451 | public static X_inv48 instance() { | ||
452 | try{ | ||
453 | return LazyHolder.INSTANCE; | ||
454 | } catch (ExceptionInInitializerError err) { | ||
455 | throw processInitializerError(err); | ||
456 | } | ||
457 | } | ||
458 | |||
459 | @Override | ||
460 | protected X_inv48.Matcher instantiate(final ViatraQueryEngine engine) { | ||
461 | return X_inv48.Matcher.on(engine); | ||
462 | } | ||
463 | |||
464 | @Override | ||
465 | public X_inv48.Matcher instantiate() { | ||
466 | return X_inv48.Matcher.create(); | ||
467 | } | ||
468 | |||
469 | @Override | ||
470 | public X_inv48.Match newEmptyMatch() { | ||
471 | return X_inv48.Match.newEmptyMatch(); | ||
472 | } | ||
473 | |||
474 | @Override | ||
475 | public X_inv48.Match newMatch(final Object... parameters) { | ||
476 | return X_inv48.Match.newMatch((Taxation.Physical_Person) parameters[0]); | ||
477 | } | ||
478 | |||
479 | /** | ||
480 | * Inner class allowing the singleton instance of {@link X_inv48} to be created | ||
481 | * <b>not</b> at the class load time of the outer class, | ||
482 | * but rather at the first call to {@link X_inv48#instance()}. | ||
483 | * | ||
484 | * <p> This workaround is required e.g. to support recursion. | ||
485 | * | ||
486 | */ | ||
487 | private static class LazyHolder { | ||
488 | private static final X_inv48 INSTANCE = new X_inv48(); | ||
489 | |||
490 | /** | ||
491 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
492 | * This initialization order is required to support indirect recursion. | ||
493 | * | ||
494 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
495 | * | ||
496 | */ | ||
497 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
498 | |||
499 | public static Object ensureInitialized() { | ||
500 | INSTANCE.ensureInitializedInternal(); | ||
501 | return null; | ||
502 | } | ||
503 | } | ||
504 | |||
505 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
506 | private static final X_inv48.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
507 | |||
508 | private final PParameter parameter_p = new PParameter("p", "Taxation.Physical_Person", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http:///TaxCard.ecore", "Physical_Person")), PParameterDirection.INOUT); | ||
509 | |||
510 | private final List<PParameter> parameters = Arrays.asList(parameter_p); | ||
511 | |||
512 | private GeneratedPQuery() { | ||
513 | super(PVisibility.PUBLIC); | ||
514 | } | ||
515 | |||
516 | @Override | ||
517 | public String getFullyQualifiedName() { | ||
518 | return "queries.x_inv48"; | ||
519 | } | ||
520 | |||
521 | @Override | ||
522 | public List<String> getParameterNames() { | ||
523 | return Arrays.asList("p"); | ||
524 | } | ||
525 | |||
526 | @Override | ||
527 | public List<PParameter> getParameters() { | ||
528 | return parameters; | ||
529 | } | ||
530 | |||
531 | @Override | ||
532 | public Set<PBody> doGetContainedBodies() { | ||
533 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
534 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
535 | { | ||
536 | PBody body = new PBody(this); | ||
537 | PVariable var_p = body.getOrCreateVariableByName("p"); | ||
538 | new TypeConstraint(body, Tuples.flatTupleOf(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Physical_Person"))); | ||
539 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
540 | new ExportedParameter(body, var_p, parameter_p) | ||
541 | )); | ||
542 | // Physical_Person.disability_type(p, ::NONE) | ||
543 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
544 | new ConstantValue(body, var__virtual_0_, getEnumLiteral("http:///TaxCard.ecore", "Disability_Types", "NONE").getInstance()); | ||
545 | new TypeConstraint(body, Tuples.flatTupleOf(var_p), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Physical_Person"))); | ||
546 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
547 | new TypeConstraint(body, Tuples.flatTupleOf(var_p, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Physical_Person", "disability_type"))); | ||
548 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http:///TaxCard.ecore", "Disability_Types"))); | ||
549 | new Equality(body, var__virtual_1_, var__virtual_0_); | ||
550 | bodies.add(body); | ||
551 | } | ||
552 | return bodies; | ||
553 | } | ||
554 | } | ||
555 | } | ||