aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/NotSynchronizingStates.java
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/NotSynchronizingStates.java')
-rw-r--r--Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/NotSynchronizingStates.java554
1 files changed, 554 insertions, 0 deletions
diff --git a/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/NotSynchronizingStates.java b/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/NotSynchronizingStates.java
new file mode 100644
index 00000000..b9a60ca9
--- /dev/null
+++ b/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/NotSynchronizingStates.java
@@ -0,0 +1,554 @@
1/**
2 * Generated from platform:/resource/ca.mcgill.ecse.dslreasoner.standalone.test/queries/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/yakinduPatterns.vql
3 */
4package ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries;
5
6import ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Synchronization;
7import ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.HasMultipleIncomingTrainsition;
8import ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.HasMultipleOutgoingTrainsition;
9import java.util.Arrays;
10import java.util.Collection;
11import java.util.LinkedHashSet;
12import java.util.List;
13import java.util.Objects;
14import java.util.Optional;
15import java.util.Set;
16import java.util.function.Consumer;
17import java.util.stream.Collectors;
18import java.util.stream.Stream;
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.matchers.backend.QueryEvaluationHint;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
32import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
33import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
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 * {@literal @}Constraint(severity="error", message="error", key = {s})
50 * pattern notSynchronizingStates(s : Synchronization) {
51 * neg find hasMultipleOutgoingTrainsition(s);
52 * neg find hasMultipleIncomingTrainsition(s);
53 * }
54 * </pre></code>
55 *
56 * @see Matcher
57 * @see Match
58 *
59 */
60@SuppressWarnings("all")
61public final class NotSynchronizingStates extends BaseGeneratedEMFQuerySpecification<NotSynchronizingStates.Matcher> {
62 /**
63 * Pattern-specific match representation of the ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.notSynchronizingStates pattern,
64 * to be used in conjunction with {@link Matcher}.
65 *
66 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
67 * Each instance is a (possibly partial) substitution of pattern parameters,
68 * usable to represent a match of the pattern in the result of a query,
69 * or to specify the bound (fixed) input parameters when issuing a query.
70 *
71 * @see Matcher
72 *
73 */
74 public static abstract class Match extends BasePatternMatch {
75 private Synchronization fS;
76
77 private static List<String> parameterNames = makeImmutableList("s");
78
79 private Match(final Synchronization pS) {
80 this.fS = pS;
81 }
82
83 @Override
84 public Object get(final String parameterName) {
85 if ("s".equals(parameterName)) return this.fS;
86 return null;
87 }
88
89 public Synchronization getS() {
90 return this.fS;
91 }
92
93 @Override
94 public boolean set(final String parameterName, final Object newValue) {
95 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
96 if ("s".equals(parameterName) ) {
97 this.fS = (Synchronization) newValue;
98 return true;
99 }
100 return false;
101 }
102
103 public void setS(final Synchronization pS) {
104 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
105 this.fS = pS;
106 }
107
108 @Override
109 public String patternName() {
110 return "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.notSynchronizingStates";
111 }
112
113 @Override
114 public List<String> parameterNames() {
115 return NotSynchronizingStates.Match.parameterNames;
116 }
117
118 @Override
119 public Object[] toArray() {
120 return new Object[]{fS};
121 }
122
123 @Override
124 public NotSynchronizingStates.Match toImmutable() {
125 return isMutable() ? newMatch(fS) : this;
126 }
127
128 @Override
129 public String prettyPrint() {
130 StringBuilder result = new StringBuilder();
131 result.append("\"s\"=" + prettyPrintValue(fS));
132 return result.toString();
133 }
134
135 @Override
136 public int hashCode() {
137 return Objects.hash(fS);
138 }
139
140 @Override
141 public boolean equals(final Object obj) {
142 if (this == obj)
143 return true;
144 if (obj == null) {
145 return false;
146 }
147 if ((obj instanceof NotSynchronizingStates.Match)) {
148 NotSynchronizingStates.Match other = (NotSynchronizingStates.Match) obj;
149 return Objects.equals(fS, other.fS);
150 } else {
151 // this should be infrequent
152 if (!(obj instanceof IPatternMatch)) {
153 return false;
154 }
155 IPatternMatch otherSig = (IPatternMatch) obj;
156 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
157 }
158 }
159
160 @Override
161 public NotSynchronizingStates specification() {
162 return NotSynchronizingStates.instance();
163 }
164
165 /**
166 * Returns an empty, mutable match.
167 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
168 *
169 * @return the empty match.
170 *
171 */
172 public static NotSynchronizingStates.Match newEmptyMatch() {
173 return new Mutable(null);
174 }
175
176 /**
177 * Returns a mutable (partial) match.
178 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
179 *
180 * @param pS the fixed value of pattern parameter s, or null if not bound.
181 * @return the new, mutable (partial) match object.
182 *
183 */
184 public static NotSynchronizingStates.Match newMutableMatch(final Synchronization pS) {
185 return new Mutable(pS);
186 }
187
188 /**
189 * Returns a new (partial) match.
190 * This can be used e.g. to call the matcher with a partial match.
191 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
192 * @param pS the fixed value of pattern parameter s, or null if not bound.
193 * @return the (partial) match object.
194 *
195 */
196 public static NotSynchronizingStates.Match newMatch(final Synchronization pS) {
197 return new Immutable(pS);
198 }
199
200 private static final class Mutable extends NotSynchronizingStates.Match {
201 Mutable(final Synchronization pS) {
202 super(pS);
203 }
204
205 @Override
206 public boolean isMutable() {
207 return true;
208 }
209 }
210
211 private static final class Immutable extends NotSynchronizingStates.Match {
212 Immutable(final Synchronization pS) {
213 super(pS);
214 }
215
216 @Override
217 public boolean isMutable() {
218 return false;
219 }
220 }
221 }
222
223 /**
224 * Generated pattern matcher API of the ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.notSynchronizingStates pattern,
225 * providing pattern-specific query methods.
226 *
227 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
228 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
229 *
230 * <p>Matches of the pattern will be represented as {@link Match}.
231 *
232 * <p>Original source:
233 * <code><pre>
234 * {@literal @}Constraint(severity="error", message="error", key = {s})
235 * pattern notSynchronizingStates(s : Synchronization) {
236 * neg find hasMultipleOutgoingTrainsition(s);
237 * neg find hasMultipleIncomingTrainsition(s);
238 * }
239 * </pre></code>
240 *
241 * @see Match
242 * @see NotSynchronizingStates
243 *
244 */
245 public static class Matcher extends BaseMatcher<NotSynchronizingStates.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 NotSynchronizingStates.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 NotSynchronizingStates.Matcher create() {
270 return new Matcher();
271 }
272
273 private final static int POSITION_S = 0;
274
275 private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NotSynchronizingStates.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 pS the fixed value of pattern parameter s, or null if not bound.
292 * @return matches represented as a Match object.
293 *
294 */
295 public Collection<NotSynchronizingStates.Match> getAllMatches(final Synchronization pS) {
296 return rawStreamAllMatches(new Object[]{pS}).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 pS the fixed value of pattern parameter s, or null if not bound.
306 * @return a stream of matches represented as a Match object.
307 *
308 */
309 public Stream<NotSynchronizingStates.Match> streamAllMatches(final Synchronization pS) {
310 return rawStreamAllMatches(new Object[]{pS});
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 pS the fixed value of pattern parameter s, 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<NotSynchronizingStates.Match> getOneArbitraryMatch(final Synchronization pS) {
321 return rawGetOneArbitraryMatch(new Object[]{pS});
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 pS the fixed value of pattern parameter s, 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 Synchronization pS) {
332 return rawHasMatch(new Object[]{pS});
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 pS the fixed value of pattern parameter s, or null if not bound.
338 * @return the number of pattern matches found.
339 *
340 */
341 public int countMatches(final Synchronization pS) {
342 return rawCountMatches(new Object[]{pS});
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 pS the fixed value of pattern parameter s, 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 Synchronization pS, final Consumer<? super NotSynchronizingStates.Match> processor) {
354 return rawForOneArbitraryMatch(new Object[]{pS}, 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 pS the fixed value of pattern parameter s, or null if not bound.
362 * @return the (partial) match object.
363 *
364 */
365 public NotSynchronizingStates.Match newMatch(final Synchronization pS) {
366 return NotSynchronizingStates.Match.newMatch(pS);
367 }
368
369 /**
370 * Retrieve the set of values that occur in matches for s.
371 * @return the Set of all values or empty set if there are no matches
372 *
373 */
374 protected Stream<Synchronization> rawStreamAllValuesOfs(final Object[] parameters) {
375 return rawStreamAllValues(POSITION_S, parameters).map(Synchronization.class::cast);
376 }
377
378 /**
379 * Retrieve the set of values that occur in matches for s.
380 * @return the Set of all values or empty set if there are no matches
381 *
382 */
383 public Set<Synchronization> getAllValuesOfs() {
384 return rawStreamAllValuesOfs(emptyArray()).collect(Collectors.toSet());
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 public Stream<Synchronization> streamAllValuesOfs() {
393 return rawStreamAllValuesOfs(emptyArray());
394 }
395
396 @Override
397 protected NotSynchronizingStates.Match tupleToMatch(final Tuple t) {
398 try {
399 return NotSynchronizingStates.Match.newMatch((Synchronization) t.get(POSITION_S));
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 NotSynchronizingStates.Match arrayToMatch(final Object[] match) {
408 try {
409 return NotSynchronizingStates.Match.newMatch((Synchronization) match[POSITION_S]);
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 NotSynchronizingStates.Match arrayToMatchMutable(final Object[] match) {
418 try {
419 return NotSynchronizingStates.Match.newMutableMatch((Synchronization) match[POSITION_S]);
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<NotSynchronizingStates.Matcher> querySpecification() {
432 return NotSynchronizingStates.instance();
433 }
434 }
435
436 private NotSynchronizingStates() {
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 NotSynchronizingStates instance() {
446 try{
447 return LazyHolder.INSTANCE;
448 } catch (ExceptionInInitializerError err) {
449 throw processInitializerError(err);
450 }
451 }
452
453 @Override
454 protected NotSynchronizingStates.Matcher instantiate(final ViatraQueryEngine engine) {
455 return NotSynchronizingStates.Matcher.on(engine);
456 }
457
458 @Override
459 public NotSynchronizingStates.Matcher instantiate() {
460 return NotSynchronizingStates.Matcher.create();
461 }
462
463 @Override
464 public NotSynchronizingStates.Match newEmptyMatch() {
465 return NotSynchronizingStates.Match.newEmptyMatch();
466 }
467
468 @Override
469 public NotSynchronizingStates.Match newMatch(final Object... parameters) {
470 return NotSynchronizingStates.Match.newMatch((ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Synchronization) parameters[0]);
471 }
472
473 /**
474 * Inner class allowing the singleton instance of {@link JvmGenericType: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.NotSynchronizingStates (visibility: PUBLIC, simpleName: NotSynchronizingStates, identifier: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.NotSynchronizingStates, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} 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 JvmGenericType: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.NotSynchronizingStates (visibility: PUBLIC, simpleName: NotSynchronizingStates, identifier: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.NotSynchronizingStates, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
477 *
478 * <p> This workaround is required e.g. to support recursion.
479 *
480 */
481 private static class LazyHolder {
482 private final static NotSynchronizingStates INSTANCE = new NotSynchronizingStates();
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 final static 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 final static NotSynchronizingStates.GeneratedPQuery INSTANCE = new GeneratedPQuery();
501
502 private final PParameter parameter_s = new PParameter("s", "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Synchronization", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("YakinduMetamodel", "Synchronization")), PParameterDirection.INOUT);
503
504 private final List<PParameter> parameters = Arrays.asList(parameter_s);
505
506 private GeneratedPQuery() {
507 super(PVisibility.PUBLIC);
508 }
509
510 @Override
511 public String getFullyQualifiedName() {
512 return "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.notSynchronizingStates";
513 }
514
515 @Override
516 public List<String> getParameterNames() {
517 return Arrays.asList("s");
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_s = body.getOrCreateVariableByName("s");
532 new TypeConstraint(body, Tuples.flatTupleOf(var_s), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Synchronization")));
533 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
534 new ExportedParameter(body, var_s, parameter_s)
535 ));
536 // neg find hasMultipleOutgoingTrainsition(s)
537 new NegativePatternCall(body, Tuples.flatTupleOf(var_s), HasMultipleOutgoingTrainsition.instance().getInternalQueryRepresentation());
538 // neg find hasMultipleIncomingTrainsition(s)
539 new NegativePatternCall(body, Tuples.flatTupleOf(var_s), HasMultipleIncomingTrainsition.instance().getInternalQueryRepresentation());
540 bodies.add(body);
541 }
542 {
543 PAnnotation annotation = new PAnnotation("Constraint");
544 annotation.addAttribute("severity", "error");
545 annotation.addAttribute("message", "error");
546 annotation.addAttribute("key", Arrays.asList(new Object[] {
547 new ParameterReference("s")
548 }));
549 addAnnotation(annotation);
550 }
551 return bodies;
552 }
553 }
554}