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