aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Turnout.java
diff options
context:
space:
mode:
Diffstat (limited to 'Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Turnout.java')
-rw-r--r--Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Turnout.java543
1 files changed, 0 insertions, 543 deletions
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Turnout.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Turnout.java
deleted file mode 100644
index 34c7631c..00000000
--- a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/Turnout.java
+++ /dev/null
@@ -1,543 +0,0 @@
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 org.apache.log4j.Logger;
17import org.eclipse.emf.ecore.EClass;
18import org.eclipse.viatra.query.runtime.api.IPatternMatch;
19import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
20import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
21import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
23import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
24import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
25import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
26import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
27import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
28import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
29import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
30import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
31import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
32import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
33import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
34import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
35import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
36import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
37
38/**
39 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
40 *
41 * <p>Original source:
42 * <code><pre>
43 * pattern turnout(T : Turnout) {
44 * Turnout(T);
45 * }
46 * </pre></code>
47 *
48 * @see Matcher
49 * @see Match
50 *
51 */
52@SuppressWarnings("all")
53public final class Turnout extends BaseGeneratedEMFQuerySpecification<Turnout.Matcher> {
54 /**
55 * Pattern-specific match representation of the modes3.queries.turnout pattern,
56 * to be used in conjunction with {@link Matcher}.
57 *
58 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
59 * Each instance is a (possibly partial) substitution of pattern parameters,
60 * usable to represent a match of the pattern in the result of a query,
61 * or to specify the bound (fixed) input parameters when issuing a query.
62 *
63 * @see Matcher
64 *
65 */
66 public static abstract class Match extends BasePatternMatch {
67 private modes3.Turnout fT;
68
69 private static List<String> parameterNames = makeImmutableList("T");
70
71 private Match(final modes3.Turnout pT) {
72 this.fT = pT;
73 }
74
75 @Override
76 public Object get(final String parameterName) {
77 switch(parameterName) {
78 case "T": return this.fT;
79 default: return null;
80 }
81 }
82
83 @Override
84 public Object get(final int index) {
85 switch(index) {
86 case 0: return this.fT;
87 default: return null;
88 }
89 }
90
91 public modes3.Turnout getT() {
92 return this.fT;
93 }
94
95 @Override
96 public boolean set(final String parameterName, final Object newValue) {
97 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
98 if ("T".equals(parameterName) ) {
99 this.fT = (modes3.Turnout) newValue;
100 return true;
101 }
102 return false;
103 }
104
105 public void setT(final modes3.Turnout pT) {
106 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
107 this.fT = pT;
108 }
109
110 @Override
111 public String patternName() {
112 return "modes3.queries.turnout";
113 }
114
115 @Override
116 public List<String> parameterNames() {
117 return Turnout.Match.parameterNames;
118 }
119
120 @Override
121 public Object[] toArray() {
122 return new Object[]{fT};
123 }
124
125 @Override
126 public Turnout.Match toImmutable() {
127 return isMutable() ? newMatch(fT) : this;
128 }
129
130 @Override
131 public String prettyPrint() {
132 StringBuilder result = new StringBuilder();
133 result.append("\"T\"=" + prettyPrintValue(fT));
134 return result.toString();
135 }
136
137 @Override
138 public int hashCode() {
139 return Objects.hash(fT);
140 }
141
142 @Override
143 public boolean equals(final Object obj) {
144 if (this == obj)
145 return true;
146 if (obj == null) {
147 return false;
148 }
149 if ((obj instanceof Turnout.Match)) {
150 Turnout.Match other = (Turnout.Match) obj;
151 return Objects.equals(fT, other.fT);
152 } else {
153 // this should be infrequent
154 if (!(obj instanceof IPatternMatch)) {
155 return false;
156 }
157 IPatternMatch otherSig = (IPatternMatch) obj;
158 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
159 }
160 }
161
162 @Override
163 public Turnout specification() {
164 return Turnout.instance();
165 }
166
167 /**
168 * Returns an empty, mutable match.
169 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
170 *
171 * @return the empty match.
172 *
173 */
174 public static Turnout.Match newEmptyMatch() {
175 return new Mutable(null);
176 }
177
178 /**
179 * Returns a mutable (partial) match.
180 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
181 *
182 * @param pT the fixed value of pattern parameter T, or null if not bound.
183 * @return the new, mutable (partial) match object.
184 *
185 */
186 public static Turnout.Match newMutableMatch(final modes3.Turnout pT) {
187 return new Mutable(pT);
188 }
189
190 /**
191 * Returns a new (partial) match.
192 * This can be used e.g. to call the matcher with a partial match.
193 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
194 * @param pT the fixed value of pattern parameter T, or null if not bound.
195 * @return the (partial) match object.
196 *
197 */
198 public static Turnout.Match newMatch(final modes3.Turnout pT) {
199 return new Immutable(pT);
200 }
201
202 private static final class Mutable extends Turnout.Match {
203 Mutable(final modes3.Turnout pT) {
204 super(pT);
205 }
206
207 @Override
208 public boolean isMutable() {
209 return true;
210 }
211 }
212
213 private static final class Immutable extends Turnout.Match {
214 Immutable(final modes3.Turnout pT) {
215 super(pT);
216 }
217
218 @Override
219 public boolean isMutable() {
220 return false;
221 }
222 }
223 }
224
225 /**
226 * Generated pattern matcher API of the modes3.queries.turnout pattern,
227 * providing pattern-specific query methods.
228 *
229 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
230 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
231 *
232 * <p>Matches of the pattern will be represented as {@link Match}.
233 *
234 * <p>Original source:
235 * <code><pre>
236 * pattern turnout(T : Turnout) {
237 * Turnout(T);
238 * }
239 * </pre></code>
240 *
241 * @see Match
242 * @see Turnout
243 *
244 */
245 public static class Matcher extends BaseMatcher<Turnout.Match> {
246 /**
247 * Initializes the pattern matcher within an existing VIATRA Query engine.
248 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
249 *
250 * @param engine the existing VIATRA Query engine in which this matcher will be created.
251 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
252 *
253 */
254 public static Turnout.Matcher on(final ViatraQueryEngine engine) {
255 // check if matcher already exists
256 Matcher matcher = engine.getExistingMatcher(querySpecification());
257 if (matcher == null) {
258 matcher = (Matcher)engine.getMatcher(querySpecification());
259 }
260 return matcher;
261 }
262
263 /**
264 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
265 * @return an initialized matcher
266 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
267 *
268 */
269 public static Turnout.Matcher create() {
270 return new Matcher();
271 }
272
273 private static final int POSITION_T = 0;
274
275 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Turnout.Matcher.class);
276
277 /**
278 * Initializes the pattern matcher within an existing VIATRA Query engine.
279 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
280 *
281 * @param engine the existing VIATRA Query engine in which this matcher will be created.
282 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
283 *
284 */
285 private Matcher() {
286 super(querySpecification());
287 }
288
289 /**
290 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
291 * @param pT the fixed value of pattern parameter T, or null if not bound.
292 * @return matches represented as a Match object.
293 *
294 */
295 public Collection<Turnout.Match> getAllMatches(final modes3.Turnout pT) {
296 return rawStreamAllMatches(new Object[]{pT}).collect(Collectors.toSet());
297 }
298
299 /**
300 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
301 * </p>
302 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
303 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
304 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
305 * @param pT the fixed value of pattern parameter T, or null if not bound.
306 * @return a stream of matches represented as a Match object.
307 *
308 */
309 public Stream<Turnout.Match> streamAllMatches(final modes3.Turnout pT) {
310 return rawStreamAllMatches(new Object[]{pT});
311 }
312
313 /**
314 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
315 * Neither determinism nor randomness of selection is guaranteed.
316 * @param pT the fixed value of pattern parameter T, or null if not bound.
317 * @return a match represented as a Match object, or null if no match is found.
318 *
319 */
320 public Optional<Turnout.Match> getOneArbitraryMatch(final modes3.Turnout pT) {
321 return rawGetOneArbitraryMatch(new Object[]{pT});
322 }
323
324 /**
325 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
326 * under any possible substitution of the unspecified parameters (if any).
327 * @param pT the fixed value of pattern parameter T, or null if not bound.
328 * @return true if the input is a valid (partial) match of the pattern.
329 *
330 */
331 public boolean hasMatch(final modes3.Turnout pT) {
332 return rawHasMatch(new Object[]{pT});
333 }
334
335 /**
336 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
337 * @param pT the fixed value of pattern parameter T, or null if not bound.
338 * @return the number of pattern matches found.
339 *
340 */
341 public int countMatches(final modes3.Turnout pT) {
342 return rawCountMatches(new Object[]{pT});
343 }
344
345 /**
346 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
347 * Neither determinism nor randomness of selection is guaranteed.
348 * @param pT the fixed value of pattern parameter T, or null if not bound.
349 * @param processor the action that will process the selected match.
350 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
351 *
352 */
353 public boolean forOneArbitraryMatch(final modes3.Turnout pT, final Consumer<? super Turnout.Match> processor) {
354 return rawForOneArbitraryMatch(new Object[]{pT}, processor);
355 }
356
357 /**
358 * Returns a new (partial) match.
359 * This can be used e.g. to call the matcher with a partial match.
360 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
361 * @param pT the fixed value of pattern parameter T, or null if not bound.
362 * @return the (partial) match object.
363 *
364 */
365 public Turnout.Match newMatch(final modes3.Turnout pT) {
366 return Turnout.Match.newMatch(pT);
367 }
368
369 /**
370 * Retrieve the set of values that occur in matches for T.
371 * @return the Set of all values or empty set if there are no matches
372 *
373 */
374 protected Stream<modes3.Turnout> rawStreamAllValuesOfT(final Object[] parameters) {
375 return rawStreamAllValues(POSITION_T, parameters).map(modes3.Turnout.class::cast);
376 }
377
378 /**
379 * Retrieve the set of values that occur in matches for T.
380 * @return the Set of all values or empty set if there are no matches
381 *
382 */
383 public Set<modes3.Turnout> getAllValuesOfT() {
384 return rawStreamAllValuesOfT(emptyArray()).collect(Collectors.toSet());
385 }
386
387 /**
388 * Retrieve the set of values that occur in matches for T.
389 * @return the Set of all values or empty set if there are no matches
390 *
391 */
392 public Stream<modes3.Turnout> streamAllValuesOfT() {
393 return rawStreamAllValuesOfT(emptyArray());
394 }
395
396 @Override
397 protected Turnout.Match tupleToMatch(final Tuple t) {
398 try {
399 return Turnout.Match.newMatch((modes3.Turnout) t.get(POSITION_T));
400 } catch(ClassCastException e) {
401 LOGGER.error("Element(s) in tuple not properly typed!",e);
402 return null;
403 }
404 }
405
406 @Override
407 protected Turnout.Match arrayToMatch(final Object[] match) {
408 try {
409 return Turnout.Match.newMatch((modes3.Turnout) match[POSITION_T]);
410 } catch(ClassCastException e) {
411 LOGGER.error("Element(s) in array not properly typed!",e);
412 return null;
413 }
414 }
415
416 @Override
417 protected Turnout.Match arrayToMatchMutable(final Object[] match) {
418 try {
419 return Turnout.Match.newMutableMatch((modes3.Turnout) match[POSITION_T]);
420 } catch(ClassCastException e) {
421 LOGGER.error("Element(s) in array not properly typed!",e);
422 return null;
423 }
424 }
425
426 /**
427 * @return the singleton instance of the query specification of this pattern
428 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
429 *
430 */
431 public static IQuerySpecification<Turnout.Matcher> querySpecification() {
432 return Turnout.instance();
433 }
434 }
435
436 private Turnout() {
437 super(GeneratedPQuery.INSTANCE);
438 }
439
440 /**
441 * @return the singleton instance of the query specification
442 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
443 *
444 */
445 public static Turnout instance() {
446 try{
447 return LazyHolder.INSTANCE;
448 } catch (ExceptionInInitializerError err) {
449 throw processInitializerError(err);
450 }
451 }
452
453 @Override
454 protected Turnout.Matcher instantiate(final ViatraQueryEngine engine) {
455 return Turnout.Matcher.on(engine);
456 }
457
458 @Override
459 public Turnout.Matcher instantiate() {
460 return Turnout.Matcher.create();
461 }
462
463 @Override
464 public Turnout.Match newEmptyMatch() {
465 return Turnout.Match.newEmptyMatch();
466 }
467
468 @Override
469 public Turnout.Match newMatch(final Object... parameters) {
470 return Turnout.Match.newMatch((modes3.Turnout) parameters[0]);
471 }
472
473 /**
474 * Inner class allowing the singleton instance of {@link Turnout} to be created
475 * <b>not</b> at the class load time of the outer class,
476 * but rather at the first call to {@link Turnout#instance()}.
477 *
478 * <p> This workaround is required e.g. to support recursion.
479 *
480 */
481 private static class LazyHolder {
482 private static final Turnout INSTANCE = new Turnout();
483
484 /**
485 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
486 * This initialization order is required to support indirect recursion.
487 *
488 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
489 *
490 */
491 private static final Object STATIC_INITIALIZER = ensureInitialized();
492
493 public static Object ensureInitialized() {
494 INSTANCE.ensureInitializedInternal();
495 return null;
496 }
497 }
498
499 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
500 private static final Turnout.GeneratedPQuery INSTANCE = new GeneratedPQuery();
501
502 private final PParameter parameter_T = new PParameter("T", "modes3.Turnout", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")), PParameterDirection.INOUT);
503
504 private final List<PParameter> parameters = Arrays.asList(parameter_T);
505
506 private GeneratedPQuery() {
507 super(PVisibility.PUBLIC);
508 }
509
510 @Override
511 public String getFullyQualifiedName() {
512 return "modes3.queries.turnout";
513 }
514
515 @Override
516 public List<String> getParameterNames() {
517 return Arrays.asList("T");
518 }
519
520 @Override
521 public List<PParameter> getParameters() {
522 return parameters;
523 }
524
525 @Override
526 public Set<PBody> doGetContainedBodies() {
527 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
528 Set<PBody> bodies = new LinkedHashSet<>();
529 {
530 PBody body = new PBody(this);
531 PVariable var_T = body.getOrCreateVariableByName("T");
532 new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")));
533 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
534 new ExportedParameter(body, var_T, parameter_T)
535 ));
536 // Turnout(T)
537 new TypeConstraint(body, Tuples.flatTupleOf(var_T), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Turnout")));
538 bodies.add(body);
539 }
540 return bodies;
541 }
542 }
543}