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