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