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