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