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