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