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