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