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