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