aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedIncomingInSameRegion.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/SynchronizedIncomingInSameRegion.java')
-rw-r--r--Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedIncomingInSameRegion.java888
1 files changed, 888 insertions, 0 deletions
diff --git a/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedIncomingInSameRegion.java b/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedIncomingInSameRegion.java
new file mode 100644
index 00000000..dabbe8c5
--- /dev/null
+++ b/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedIncomingInSameRegion.java
@@ -0,0 +1,888 @@
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 ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Vertex;
8import ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.Transition;
9import java.util.Arrays;
10import java.util.Collection;
11import java.util.LinkedHashSet;
12import java.util.List;
13import java.util.Objects;
14import java.util.Optional;
15import java.util.Set;
16import java.util.function.Consumer;
17import java.util.stream.Collectors;
18import java.util.stream.Stream;
19import org.apache.log4j.Logger;
20import org.eclipse.emf.ecore.EClass;
21import org.eclipse.viatra.query.runtime.api.IPatternMatch;
22import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
23import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
25import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
26import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
27import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
28import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
29import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
30import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
32import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
33import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
34import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
39import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
42import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
44import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
45import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
46
47/**
48 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
49 *
50 * <p>Original source:
51 * <code><pre>
52 * {@literal @}Constraint(severity="error", message="error", key = {s})
53 * pattern SynchronizedIncomingInSameRegion(s : Synchronization, v1 : Vertex, v2 : Vertex) {
54 * find transition(t1, v1, s);
55 * find transition(t2, v2, s);
56 * t1!=t2;
57 * Region.vertices(r, v1);
58 * Region.vertices(r, v2);
59 * } or {
60 * find transition(t1, s, v1);
61 * find transition(t2, s, v2);
62 * t1!=t2;
63 * Region.vertices(r, v1);
64 * Region.vertices(r, v2);
65 * }
66 * </pre></code>
67 *
68 * @see Matcher
69 * @see Match
70 *
71 */
72@SuppressWarnings("all")
73public final class SynchronizedIncomingInSameRegion extends BaseGeneratedEMFQuerySpecification<SynchronizedIncomingInSameRegion.Matcher> {
74 /**
75 * Pattern-specific match representation of the ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedIncomingInSameRegion pattern,
76 * to be used in conjunction with {@link Matcher}.
77 *
78 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
79 * Each instance is a (possibly partial) substitution of pattern parameters,
80 * usable to represent a match of the pattern in the result of a query,
81 * or to specify the bound (fixed) input parameters when issuing a query.
82 *
83 * @see Matcher
84 *
85 */
86 public static abstract class Match extends BasePatternMatch {
87 private Synchronization fS;
88
89 private Vertex fV1;
90
91 private Vertex fV2;
92
93 private static List<String> parameterNames = makeImmutableList("s", "v1", "v2");
94
95 private Match(final Synchronization pS, final Vertex pV1, final Vertex pV2) {
96 this.fS = pS;
97 this.fV1 = pV1;
98 this.fV2 = pV2;
99 }
100
101 @Override
102 public Object get(final String parameterName) {
103 if ("s".equals(parameterName)) return this.fS;
104 if ("v1".equals(parameterName)) return this.fV1;
105 if ("v2".equals(parameterName)) return this.fV2;
106 return null;
107 }
108
109 public Synchronization getS() {
110 return this.fS;
111 }
112
113 public Vertex getV1() {
114 return this.fV1;
115 }
116
117 public Vertex getV2() {
118 return this.fV2;
119 }
120
121 @Override
122 public boolean set(final String parameterName, final Object newValue) {
123 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
124 if ("s".equals(parameterName) ) {
125 this.fS = (Synchronization) newValue;
126 return true;
127 }
128 if ("v1".equals(parameterName) ) {
129 this.fV1 = (Vertex) newValue;
130 return true;
131 }
132 if ("v2".equals(parameterName) ) {
133 this.fV2 = (Vertex) newValue;
134 return true;
135 }
136 return false;
137 }
138
139 public void setS(final Synchronization pS) {
140 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
141 this.fS = pS;
142 }
143
144 public void setV1(final Vertex pV1) {
145 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
146 this.fV1 = pV1;
147 }
148
149 public void setV2(final Vertex pV2) {
150 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
151 this.fV2 = pV2;
152 }
153
154 @Override
155 public String patternName() {
156 return "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedIncomingInSameRegion";
157 }
158
159 @Override
160 public List<String> parameterNames() {
161 return SynchronizedIncomingInSameRegion.Match.parameterNames;
162 }
163
164 @Override
165 public Object[] toArray() {
166 return new Object[]{fS, fV1, fV2};
167 }
168
169 @Override
170 public SynchronizedIncomingInSameRegion.Match toImmutable() {
171 return isMutable() ? newMatch(fS, fV1, fV2) : this;
172 }
173
174 @Override
175 public String prettyPrint() {
176 StringBuilder result = new StringBuilder();
177 result.append("\"s\"=" + prettyPrintValue(fS) + ", ");
178 result.append("\"v1\"=" + prettyPrintValue(fV1) + ", ");
179 result.append("\"v2\"=" + prettyPrintValue(fV2));
180 return result.toString();
181 }
182
183 @Override
184 public int hashCode() {
185 return Objects.hash(fS, fV1, fV2);
186 }
187
188 @Override
189 public boolean equals(final Object obj) {
190 if (this == obj)
191 return true;
192 if (obj == null) {
193 return false;
194 }
195 if ((obj instanceof SynchronizedIncomingInSameRegion.Match)) {
196 SynchronizedIncomingInSameRegion.Match other = (SynchronizedIncomingInSameRegion.Match) obj;
197 return Objects.equals(fS, other.fS) && Objects.equals(fV1, other.fV1) && Objects.equals(fV2, other.fV2);
198 } else {
199 // this should be infrequent
200 if (!(obj instanceof IPatternMatch)) {
201 return false;
202 }
203 IPatternMatch otherSig = (IPatternMatch) obj;
204 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
205 }
206 }
207
208 @Override
209 public SynchronizedIncomingInSameRegion specification() {
210 return SynchronizedIncomingInSameRegion.instance();
211 }
212
213 /**
214 * Returns an empty, mutable match.
215 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
216 *
217 * @return the empty match.
218 *
219 */
220 public static SynchronizedIncomingInSameRegion.Match newEmptyMatch() {
221 return new Mutable(null, null, null);
222 }
223
224 /**
225 * Returns a mutable (partial) match.
226 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
227 *
228 * @param pS the fixed value of pattern parameter s, or null if not bound.
229 * @param pV1 the fixed value of pattern parameter v1, or null if not bound.
230 * @param pV2 the fixed value of pattern parameter v2, or null if not bound.
231 * @return the new, mutable (partial) match object.
232 *
233 */
234 public static SynchronizedIncomingInSameRegion.Match newMutableMatch(final Synchronization pS, final Vertex pV1, final Vertex pV2) {
235 return new Mutable(pS, pV1, pV2);
236 }
237
238 /**
239 * Returns a new (partial) match.
240 * This can be used e.g. to call the matcher with a partial match.
241 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
242 * @param pS the fixed value of pattern parameter s, or null if not bound.
243 * @param pV1 the fixed value of pattern parameter v1, or null if not bound.
244 * @param pV2 the fixed value of pattern parameter v2, or null if not bound.
245 * @return the (partial) match object.
246 *
247 */
248 public static SynchronizedIncomingInSameRegion.Match newMatch(final Synchronization pS, final Vertex pV1, final Vertex pV2) {
249 return new Immutable(pS, pV1, pV2);
250 }
251
252 private static final class Mutable extends SynchronizedIncomingInSameRegion.Match {
253 Mutable(final Synchronization pS, final Vertex pV1, final Vertex pV2) {
254 super(pS, pV1, pV2);
255 }
256
257 @Override
258 public boolean isMutable() {
259 return true;
260 }
261 }
262
263 private static final class Immutable extends SynchronizedIncomingInSameRegion.Match {
264 Immutable(final Synchronization pS, final Vertex pV1, final Vertex pV2) {
265 super(pS, pV1, pV2);
266 }
267
268 @Override
269 public boolean isMutable() {
270 return false;
271 }
272 }
273 }
274
275 /**
276 * Generated pattern matcher API of the ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedIncomingInSameRegion pattern,
277 * providing pattern-specific query methods.
278 *
279 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
280 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
281 *
282 * <p>Matches of the pattern will be represented as {@link Match}.
283 *
284 * <p>Original source:
285 * <code><pre>
286 * {@literal @}Constraint(severity="error", message="error", key = {s})
287 * pattern SynchronizedIncomingInSameRegion(s : Synchronization, v1 : Vertex, v2 : Vertex) {
288 * find transition(t1, v1, s);
289 * find transition(t2, v2, s);
290 * t1!=t2;
291 * Region.vertices(r, v1);
292 * Region.vertices(r, v2);
293 * } or {
294 * find transition(t1, s, v1);
295 * find transition(t2, s, v2);
296 * t1!=t2;
297 * Region.vertices(r, v1);
298 * Region.vertices(r, v2);
299 * }
300 * </pre></code>
301 *
302 * @see Match
303 * @see SynchronizedIncomingInSameRegion
304 *
305 */
306 public static class Matcher extends BaseMatcher<SynchronizedIncomingInSameRegion.Match> {
307 /**
308 * Initializes the pattern matcher within an existing VIATRA Query engine.
309 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
310 *
311 * @param engine the existing VIATRA Query engine in which this matcher will be created.
312 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
313 *
314 */
315 public static SynchronizedIncomingInSameRegion.Matcher on(final ViatraQueryEngine engine) {
316 // check if matcher already exists
317 Matcher matcher = engine.getExistingMatcher(querySpecification());
318 if (matcher == null) {
319 matcher = (Matcher)engine.getMatcher(querySpecification());
320 }
321 return matcher;
322 }
323
324 /**
325 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
326 * @return an initialized matcher
327 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
328 *
329 */
330 public static SynchronizedIncomingInSameRegion.Matcher create() {
331 return new Matcher();
332 }
333
334 private final static int POSITION_S = 0;
335
336 private final static int POSITION_V1 = 1;
337
338 private final static int POSITION_V2 = 2;
339
340 private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(SynchronizedIncomingInSameRegion.Matcher.class);
341
342 /**
343 * Initializes the pattern matcher within an existing VIATRA Query engine.
344 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
345 *
346 * @param engine the existing VIATRA Query engine in which this matcher will be created.
347 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
348 *
349 */
350 private Matcher() {
351 super(querySpecification());
352 }
353
354 /**
355 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
356 * @param pS the fixed value of pattern parameter s, or null if not bound.
357 * @param pV1 the fixed value of pattern parameter v1, or null if not bound.
358 * @param pV2 the fixed value of pattern parameter v2, or null if not bound.
359 * @return matches represented as a Match object.
360 *
361 */
362 public Collection<SynchronizedIncomingInSameRegion.Match> getAllMatches(final Synchronization pS, final Vertex pV1, final Vertex pV2) {
363 return rawStreamAllMatches(new Object[]{pS, pV1, pV2}).collect(Collectors.toSet());
364 }
365
366 /**
367 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
368 * </p>
369 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
370 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
371 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
372 * @param pS the fixed value of pattern parameter s, or null if not bound.
373 * @param pV1 the fixed value of pattern parameter v1, or null if not bound.
374 * @param pV2 the fixed value of pattern parameter v2, or null if not bound.
375 * @return a stream of matches represented as a Match object.
376 *
377 */
378 public Stream<SynchronizedIncomingInSameRegion.Match> streamAllMatches(final Synchronization pS, final Vertex pV1, final Vertex pV2) {
379 return rawStreamAllMatches(new Object[]{pS, pV1, pV2});
380 }
381
382 /**
383 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
384 * Neither determinism nor randomness of selection is guaranteed.
385 * @param pS the fixed value of pattern parameter s, or null if not bound.
386 * @param pV1 the fixed value of pattern parameter v1, or null if not bound.
387 * @param pV2 the fixed value of pattern parameter v2, or null if not bound.
388 * @return a match represented as a Match object, or null if no match is found.
389 *
390 */
391 public Optional<SynchronizedIncomingInSameRegion.Match> getOneArbitraryMatch(final Synchronization pS, final Vertex pV1, final Vertex pV2) {
392 return rawGetOneArbitraryMatch(new Object[]{pS, pV1, pV2});
393 }
394
395 /**
396 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
397 * under any possible substitution of the unspecified parameters (if any).
398 * @param pS the fixed value of pattern parameter s, or null if not bound.
399 * @param pV1 the fixed value of pattern parameter v1, or null if not bound.
400 * @param pV2 the fixed value of pattern parameter v2, or null if not bound.
401 * @return true if the input is a valid (partial) match of the pattern.
402 *
403 */
404 public boolean hasMatch(final Synchronization pS, final Vertex pV1, final Vertex pV2) {
405 return rawHasMatch(new Object[]{pS, pV1, pV2});
406 }
407
408 /**
409 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
410 * @param pS the fixed value of pattern parameter s, or null if not bound.
411 * @param pV1 the fixed value of pattern parameter v1, or null if not bound.
412 * @param pV2 the fixed value of pattern parameter v2, or null if not bound.
413 * @return the number of pattern matches found.
414 *
415 */
416 public int countMatches(final Synchronization pS, final Vertex pV1, final Vertex pV2) {
417 return rawCountMatches(new Object[]{pS, pV1, pV2});
418 }
419
420 /**
421 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
422 * Neither determinism nor randomness of selection is guaranteed.
423 * @param pS the fixed value of pattern parameter s, or null if not bound.
424 * @param pV1 the fixed value of pattern parameter v1, or null if not bound.
425 * @param pV2 the fixed value of pattern parameter v2, or null if not bound.
426 * @param processor the action that will process the selected match.
427 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
428 *
429 */
430 public boolean forOneArbitraryMatch(final Synchronization pS, final Vertex pV1, final Vertex pV2, final Consumer<? super SynchronizedIncomingInSameRegion.Match> processor) {
431 return rawForOneArbitraryMatch(new Object[]{pS, pV1, pV2}, processor);
432 }
433
434 /**
435 * Returns a new (partial) match.
436 * This can be used e.g. to call the matcher with a partial match.
437 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
438 * @param pS the fixed value of pattern parameter s, or null if not bound.
439 * @param pV1 the fixed value of pattern parameter v1, or null if not bound.
440 * @param pV2 the fixed value of pattern parameter v2, or null if not bound.
441 * @return the (partial) match object.
442 *
443 */
444 public SynchronizedIncomingInSameRegion.Match newMatch(final Synchronization pS, final Vertex pV1, final Vertex pV2) {
445 return SynchronizedIncomingInSameRegion.Match.newMatch(pS, pV1, pV2);
446 }
447
448 /**
449 * Retrieve the set of values that occur in matches for s.
450 * @return the Set of all values or empty set if there are no matches
451 *
452 */
453 protected Stream<Synchronization> rawStreamAllValuesOfs(final Object[] parameters) {
454 return rawStreamAllValues(POSITION_S, parameters).map(Synchronization.class::cast);
455 }
456
457 /**
458 * Retrieve the set of values that occur in matches for s.
459 * @return the Set of all values or empty set if there are no matches
460 *
461 */
462 public Set<Synchronization> getAllValuesOfs() {
463 return rawStreamAllValuesOfs(emptyArray()).collect(Collectors.toSet());
464 }
465
466 /**
467 * Retrieve the set of values that occur in matches for s.
468 * @return the Set of all values or empty set if there are no matches
469 *
470 */
471 public Stream<Synchronization> streamAllValuesOfs() {
472 return rawStreamAllValuesOfs(emptyArray());
473 }
474
475 /**
476 * Retrieve the set of values that occur in matches for s.
477 * </p>
478 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
479 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
480 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
481 *
482 * @return the Stream of all values or empty set if there are no matches
483 *
484 */
485 public Stream<Synchronization> streamAllValuesOfs(final SynchronizedIncomingInSameRegion.Match partialMatch) {
486 return rawStreamAllValuesOfs(partialMatch.toArray());
487 }
488
489 /**
490 * Retrieve the set of values that occur in matches for s.
491 * </p>
492 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
493 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
494 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
495 *
496 * @return the Stream of all values or empty set if there are no matches
497 *
498 */
499 public Stream<Synchronization> streamAllValuesOfs(final Vertex pV1, final Vertex pV2) {
500 return rawStreamAllValuesOfs(new Object[]{null, pV1, pV2});
501 }
502
503 /**
504 * Retrieve the set of values that occur in matches for s.
505 * @return the Set of all values or empty set if there are no matches
506 *
507 */
508 public Set<Synchronization> getAllValuesOfs(final SynchronizedIncomingInSameRegion.Match partialMatch) {
509 return rawStreamAllValuesOfs(partialMatch.toArray()).collect(Collectors.toSet());
510 }
511
512 /**
513 * Retrieve the set of values that occur in matches for s.
514 * @return the Set of all values or empty set if there are no matches
515 *
516 */
517 public Set<Synchronization> getAllValuesOfs(final Vertex pV1, final Vertex pV2) {
518 return rawStreamAllValuesOfs(new Object[]{null, pV1, pV2}).collect(Collectors.toSet());
519 }
520
521 /**
522 * Retrieve the set of values that occur in matches for v1.
523 * @return the Set of all values or empty set if there are no matches
524 *
525 */
526 protected Stream<Vertex> rawStreamAllValuesOfv1(final Object[] parameters) {
527 return rawStreamAllValues(POSITION_V1, parameters).map(Vertex.class::cast);
528 }
529
530 /**
531 * Retrieve the set of values that occur in matches for v1.
532 * @return the Set of all values or empty set if there are no matches
533 *
534 */
535 public Set<Vertex> getAllValuesOfv1() {
536 return rawStreamAllValuesOfv1(emptyArray()).collect(Collectors.toSet());
537 }
538
539 /**
540 * Retrieve the set of values that occur in matches for v1.
541 * @return the Set of all values or empty set if there are no matches
542 *
543 */
544 public Stream<Vertex> streamAllValuesOfv1() {
545 return rawStreamAllValuesOfv1(emptyArray());
546 }
547
548 /**
549 * Retrieve the set of values that occur in matches for v1.
550 * </p>
551 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
552 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
553 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
554 *
555 * @return the Stream of all values or empty set if there are no matches
556 *
557 */
558 public Stream<Vertex> streamAllValuesOfv1(final SynchronizedIncomingInSameRegion.Match partialMatch) {
559 return rawStreamAllValuesOfv1(partialMatch.toArray());
560 }
561
562 /**
563 * Retrieve the set of values that occur in matches for v1.
564 * </p>
565 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
566 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
567 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
568 *
569 * @return the Stream of all values or empty set if there are no matches
570 *
571 */
572 public Stream<Vertex> streamAllValuesOfv1(final Synchronization pS, final Vertex pV2) {
573 return rawStreamAllValuesOfv1(new Object[]{pS, null, pV2});
574 }
575
576 /**
577 * Retrieve the set of values that occur in matches for v1.
578 * @return the Set of all values or empty set if there are no matches
579 *
580 */
581 public Set<Vertex> getAllValuesOfv1(final SynchronizedIncomingInSameRegion.Match partialMatch) {
582 return rawStreamAllValuesOfv1(partialMatch.toArray()).collect(Collectors.toSet());
583 }
584
585 /**
586 * Retrieve the set of values that occur in matches for v1.
587 * @return the Set of all values or empty set if there are no matches
588 *
589 */
590 public Set<Vertex> getAllValuesOfv1(final Synchronization pS, final Vertex pV2) {
591 return rawStreamAllValuesOfv1(new Object[]{pS, null, pV2}).collect(Collectors.toSet());
592 }
593
594 /**
595 * Retrieve the set of values that occur in matches for v2.
596 * @return the Set of all values or empty set if there are no matches
597 *
598 */
599 protected Stream<Vertex> rawStreamAllValuesOfv2(final Object[] parameters) {
600 return rawStreamAllValues(POSITION_V2, parameters).map(Vertex.class::cast);
601 }
602
603 /**
604 * Retrieve the set of values that occur in matches for v2.
605 * @return the Set of all values or empty set if there are no matches
606 *
607 */
608 public Set<Vertex> getAllValuesOfv2() {
609 return rawStreamAllValuesOfv2(emptyArray()).collect(Collectors.toSet());
610 }
611
612 /**
613 * Retrieve the set of values that occur in matches for v2.
614 * @return the Set of all values or empty set if there are no matches
615 *
616 */
617 public Stream<Vertex> streamAllValuesOfv2() {
618 return rawStreamAllValuesOfv2(emptyArray());
619 }
620
621 /**
622 * Retrieve the set of values that occur in matches for v2.
623 * </p>
624 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
625 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
626 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
627 *
628 * @return the Stream of all values or empty set if there are no matches
629 *
630 */
631 public Stream<Vertex> streamAllValuesOfv2(final SynchronizedIncomingInSameRegion.Match partialMatch) {
632 return rawStreamAllValuesOfv2(partialMatch.toArray());
633 }
634
635 /**
636 * Retrieve the set of values that occur in matches for v2.
637 * </p>
638 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
639 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
640 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
641 *
642 * @return the Stream of all values or empty set if there are no matches
643 *
644 */
645 public Stream<Vertex> streamAllValuesOfv2(final Synchronization pS, final Vertex pV1) {
646 return rawStreamAllValuesOfv2(new Object[]{pS, pV1, null});
647 }
648
649 /**
650 * Retrieve the set of values that occur in matches for v2.
651 * @return the Set of all values or empty set if there are no matches
652 *
653 */
654 public Set<Vertex> getAllValuesOfv2(final SynchronizedIncomingInSameRegion.Match partialMatch) {
655 return rawStreamAllValuesOfv2(partialMatch.toArray()).collect(Collectors.toSet());
656 }
657
658 /**
659 * Retrieve the set of values that occur in matches for v2.
660 * @return the Set of all values or empty set if there are no matches
661 *
662 */
663 public Set<Vertex> getAllValuesOfv2(final Synchronization pS, final Vertex pV1) {
664 return rawStreamAllValuesOfv2(new Object[]{pS, pV1, null}).collect(Collectors.toSet());
665 }
666
667 @Override
668 protected SynchronizedIncomingInSameRegion.Match tupleToMatch(final Tuple t) {
669 try {
670 return SynchronizedIncomingInSameRegion.Match.newMatch((Synchronization) t.get(POSITION_S), (Vertex) t.get(POSITION_V1), (Vertex) t.get(POSITION_V2));
671 } catch(ClassCastException e) {
672 LOGGER.error("Element(s) in tuple not properly typed!",e);
673 return null;
674 }
675 }
676
677 @Override
678 protected SynchronizedIncomingInSameRegion.Match arrayToMatch(final Object[] match) {
679 try {
680 return SynchronizedIncomingInSameRegion.Match.newMatch((Synchronization) match[POSITION_S], (Vertex) match[POSITION_V1], (Vertex) match[POSITION_V2]);
681 } catch(ClassCastException e) {
682 LOGGER.error("Element(s) in array not properly typed!",e);
683 return null;
684 }
685 }
686
687 @Override
688 protected SynchronizedIncomingInSameRegion.Match arrayToMatchMutable(final Object[] match) {
689 try {
690 return SynchronizedIncomingInSameRegion.Match.newMutableMatch((Synchronization) match[POSITION_S], (Vertex) match[POSITION_V1], (Vertex) match[POSITION_V2]);
691 } catch(ClassCastException e) {
692 LOGGER.error("Element(s) in array not properly typed!",e);
693 return null;
694 }
695 }
696
697 /**
698 * @return the singleton instance of the query specification of this pattern
699 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
700 *
701 */
702 public static IQuerySpecification<SynchronizedIncomingInSameRegion.Matcher> querySpecification() {
703 return SynchronizedIncomingInSameRegion.instance();
704 }
705 }
706
707 private SynchronizedIncomingInSameRegion() {
708 super(GeneratedPQuery.INSTANCE);
709 }
710
711 /**
712 * @return the singleton instance of the query specification
713 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
714 *
715 */
716 public static SynchronizedIncomingInSameRegion instance() {
717 try{
718 return LazyHolder.INSTANCE;
719 } catch (ExceptionInInitializerError err) {
720 throw processInitializerError(err);
721 }
722 }
723
724 @Override
725 protected SynchronizedIncomingInSameRegion.Matcher instantiate(final ViatraQueryEngine engine) {
726 return SynchronizedIncomingInSameRegion.Matcher.on(engine);
727 }
728
729 @Override
730 public SynchronizedIncomingInSameRegion.Matcher instantiate() {
731 return SynchronizedIncomingInSameRegion.Matcher.create();
732 }
733
734 @Override
735 public SynchronizedIncomingInSameRegion.Match newEmptyMatch() {
736 return SynchronizedIncomingInSameRegion.Match.newEmptyMatch();
737 }
738
739 @Override
740 public SynchronizedIncomingInSameRegion.Match newMatch(final Object... parameters) {
741 return SynchronizedIncomingInSameRegion.Match.newMatch((ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Synchronization) parameters[0], (ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Vertex) parameters[1], (ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Vertex) parameters[2]);
742 }
743
744 /**
745 * Inner class allowing the singleton instance of {@link JvmGenericType: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedIncomingInSameRegion (visibility: PUBLIC, simpleName: SynchronizedIncomingInSameRegion, identifier: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedIncomingInSameRegion, 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
746 * <b>not</b> at the class load time of the outer class,
747 * but rather at the first call to {@link JvmGenericType: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedIncomingInSameRegion (visibility: PUBLIC, simpleName: SynchronizedIncomingInSameRegion, identifier: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedIncomingInSameRegion, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
748 *
749 * <p> This workaround is required e.g. to support recursion.
750 *
751 */
752 private static class LazyHolder {
753 private final static SynchronizedIncomingInSameRegion INSTANCE = new SynchronizedIncomingInSameRegion();
754
755 /**
756 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
757 * This initialization order is required to support indirect recursion.
758 *
759 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
760 *
761 */
762 private final static Object STATIC_INITIALIZER = ensureInitialized();
763
764 public static Object ensureInitialized() {
765 INSTANCE.ensureInitializedInternal();
766 return null;
767 }
768 }
769
770 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
771 private final static SynchronizedIncomingInSameRegion.GeneratedPQuery INSTANCE = new GeneratedPQuery();
772
773 private final PParameter parameter_s = new PParameter("s", "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Synchronization", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("YakinduMetamodel", "Synchronization")), PParameterDirection.INOUT);
774
775 private final PParameter parameter_v1 = new PParameter("v1", "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Vertex", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("YakinduMetamodel", "Vertex")), PParameterDirection.INOUT);
776
777 private final PParameter parameter_v2 = new PParameter("v2", "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Vertex", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("YakinduMetamodel", "Vertex")), PParameterDirection.INOUT);
778
779 private final List<PParameter> parameters = Arrays.asList(parameter_s, parameter_v1, parameter_v2);
780
781 private GeneratedPQuery() {
782 super(PVisibility.PUBLIC);
783 }
784
785 @Override
786 public String getFullyQualifiedName() {
787 return "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedIncomingInSameRegion";
788 }
789
790 @Override
791 public List<String> getParameterNames() {
792 return Arrays.asList("s","v1","v2");
793 }
794
795 @Override
796 public List<PParameter> getParameters() {
797 return parameters;
798 }
799
800 @Override
801 public Set<PBody> doGetContainedBodies() {
802 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
803 Set<PBody> bodies = new LinkedHashSet<>();
804 {
805 PBody body = new PBody(this);
806 PVariable var_s = body.getOrCreateVariableByName("s");
807 PVariable var_v1 = body.getOrCreateVariableByName("v1");
808 PVariable var_v2 = body.getOrCreateVariableByName("v2");
809 PVariable var_t1 = body.getOrCreateVariableByName("t1");
810 PVariable var_t2 = body.getOrCreateVariableByName("t2");
811 PVariable var_r = body.getOrCreateVariableByName("r");
812 new TypeConstraint(body, Tuples.flatTupleOf(var_s), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Synchronization")));
813 new TypeConstraint(body, Tuples.flatTupleOf(var_v1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Vertex")));
814 new TypeConstraint(body, Tuples.flatTupleOf(var_v2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Vertex")));
815 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
816 new ExportedParameter(body, var_s, parameter_s),
817 new ExportedParameter(body, var_v1, parameter_v1),
818 new ExportedParameter(body, var_v2, parameter_v2)
819 ));
820 // find transition(t1, v1, s)
821 new PositivePatternCall(body, Tuples.flatTupleOf(var_t1, var_v1, var_s), Transition.instance().getInternalQueryRepresentation());
822 // find transition(t2, v2, s)
823 new PositivePatternCall(body, Tuples.flatTupleOf(var_t2, var_v2, var_s), Transition.instance().getInternalQueryRepresentation());
824 // t1!=t2
825 new Inequality(body, var_t1, var_t2);
826 // Region.vertices(r, v1)
827 new TypeConstraint(body, Tuples.flatTupleOf(var_r), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Region")));
828 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
829 new TypeConstraint(body, Tuples.flatTupleOf(var_r, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("YakinduMetamodel", "Region", "vertices")));
830 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Vertex")));
831 new Equality(body, var__virtual_0_, var_v1);
832 // Region.vertices(r, v2)
833 new TypeConstraint(body, Tuples.flatTupleOf(var_r), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Region")));
834 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
835 new TypeConstraint(body, Tuples.flatTupleOf(var_r, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("YakinduMetamodel", "Region", "vertices")));
836 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Vertex")));
837 new Equality(body, var__virtual_1_, var_v2);
838 bodies.add(body);
839 }
840 {
841 PBody body = new PBody(this);
842 PVariable var_s = body.getOrCreateVariableByName("s");
843 PVariable var_v1 = body.getOrCreateVariableByName("v1");
844 PVariable var_v2 = body.getOrCreateVariableByName("v2");
845 PVariable var_t1 = body.getOrCreateVariableByName("t1");
846 PVariable var_t2 = body.getOrCreateVariableByName("t2");
847 PVariable var_r = body.getOrCreateVariableByName("r");
848 new TypeConstraint(body, Tuples.flatTupleOf(var_s), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Synchronization")));
849 new TypeConstraint(body, Tuples.flatTupleOf(var_v1), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Vertex")));
850 new TypeConstraint(body, Tuples.flatTupleOf(var_v2), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Vertex")));
851 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
852 new ExportedParameter(body, var_s, parameter_s),
853 new ExportedParameter(body, var_v1, parameter_v1),
854 new ExportedParameter(body, var_v2, parameter_v2)
855 ));
856 // find transition(t1, s, v1)
857 new PositivePatternCall(body, Tuples.flatTupleOf(var_t1, var_s, var_v1), Transition.instance().getInternalQueryRepresentation());
858 // find transition(t2, s, v2)
859 new PositivePatternCall(body, Tuples.flatTupleOf(var_t2, var_s, var_v2), Transition.instance().getInternalQueryRepresentation());
860 // t1!=t2
861 new Inequality(body, var_t1, var_t2);
862 // Region.vertices(r, v1)
863 new TypeConstraint(body, Tuples.flatTupleOf(var_r), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Region")));
864 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
865 new TypeConstraint(body, Tuples.flatTupleOf(var_r, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("YakinduMetamodel", "Region", "vertices")));
866 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Vertex")));
867 new Equality(body, var__virtual_0_, var_v1);
868 // Region.vertices(r, v2)
869 new TypeConstraint(body, Tuples.flatTupleOf(var_r), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Region")));
870 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
871 new TypeConstraint(body, Tuples.flatTupleOf(var_r, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("YakinduMetamodel", "Region", "vertices")));
872 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Vertex")));
873 new Equality(body, var__virtual_1_, var_v2);
874 bodies.add(body);
875 }
876 {
877 PAnnotation annotation = new PAnnotation("Constraint");
878 annotation.addAttribute("severity", "error");
879 annotation.addAttribute("message", "error");
880 annotation.addAttribute("key", Arrays.asList(new Object[] {
881 new ParameterReference("s")
882 }));
883 addAnnotation(annotation);
884 }
885 return bodies;
886 }
887 }
888}