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