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