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