aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/ChoiceHasNoIncoming.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/ChoiceHasNoIncoming.java')
-rw-r--r--Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/ChoiceHasNoIncoming.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/ChoiceHasNoIncoming.java b/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/ChoiceHasNoIncoming.java
new file mode 100644
index 00000000..8e62ee9d
--- /dev/null
+++ b/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/ChoiceHasNoIncoming.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.Choice;
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 = {c})
49 * pattern choiceHasNoIncoming(c: Choice) {
50 * neg find transition(_, _, c);
51 * }
52 * </pre></code>
53 *
54 * @see Matcher
55 * @see Match
56 *
57 */
58@SuppressWarnings("all")
59public final class ChoiceHasNoIncoming extends BaseGeneratedEMFQuerySpecification<ChoiceHasNoIncoming.Matcher> {
60 /**
61 * Pattern-specific match representation of the ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.choiceHasNoIncoming 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 Choice fC;
74
75 private static List<String> parameterNames = makeImmutableList("c");
76
77 private Match(final Choice pC) {
78 this.fC = pC;
79 }
80
81 @Override
82 public Object get(final String parameterName) {
83 if ("c".equals(parameterName)) return this.fC;
84 return null;
85 }
86
87 public Choice getC() {
88 return this.fC;
89 }
90
91 @Override
92 public boolean set(final String parameterName, final Object newValue) {
93 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
94 if ("c".equals(parameterName) ) {
95 this.fC = (Choice) newValue;
96 return true;
97 }
98 return false;
99 }
100
101 public void setC(final Choice pC) {
102 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
103 this.fC = pC;
104 }
105
106 @Override
107 public String patternName() {
108 return "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.choiceHasNoIncoming";
109 }
110
111 @Override
112 public List<String> parameterNames() {
113 return ChoiceHasNoIncoming.Match.parameterNames;
114 }
115
116 @Override
117 public Object[] toArray() {
118 return new Object[]{fC};
119 }
120
121 @Override
122 public ChoiceHasNoIncoming.Match toImmutable() {
123 return isMutable() ? newMatch(fC) : this;
124 }
125
126 @Override
127 public String prettyPrint() {
128 StringBuilder result = new StringBuilder();
129 result.append("\"c\"=" + prettyPrintValue(fC));
130 return result.toString();
131 }
132
133 @Override
134 public int hashCode() {
135 return Objects.hash(fC);
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 ChoiceHasNoIncoming.Match)) {
146 ChoiceHasNoIncoming.Match other = (ChoiceHasNoIncoming.Match) obj;
147 return Objects.equals(fC, other.fC);
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 ChoiceHasNoIncoming specification() {
160 return ChoiceHasNoIncoming.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 ChoiceHasNoIncoming.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 pC the fixed value of pattern parameter c, or null if not bound.
179 * @return the new, mutable (partial) match object.
180 *
181 */
182 public static ChoiceHasNoIncoming.Match newMutableMatch(final Choice pC) {
183 return new Mutable(pC);
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 pC the fixed value of pattern parameter c, or null if not bound.
191 * @return the (partial) match object.
192 *
193 */
194 public static ChoiceHasNoIncoming.Match newMatch(final Choice pC) {
195 return new Immutable(pC);
196 }
197
198 private static final class Mutable extends ChoiceHasNoIncoming.Match {
199 Mutable(final Choice pC) {
200 super(pC);
201 }
202
203 @Override
204 public boolean isMutable() {
205 return true;
206 }
207 }
208
209 private static final class Immutable extends ChoiceHasNoIncoming.Match {
210 Immutable(final Choice pC) {
211 super(pC);
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.choiceHasNoIncoming 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 = {c})
233 * pattern choiceHasNoIncoming(c: Choice) {
234 * neg find transition(_, _, c);
235 * }
236 * </pre></code>
237 *
238 * @see Match
239 * @see ChoiceHasNoIncoming
240 *
241 */
242 public static class Matcher extends BaseMatcher<ChoiceHasNoIncoming.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 ChoiceHasNoIncoming.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 ChoiceHasNoIncoming.Matcher create() {
267 return new Matcher();
268 }
269
270 private final static int POSITION_C = 0;
271
272 private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ChoiceHasNoIncoming.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 pC the fixed value of pattern parameter c, or null if not bound.
289 * @return matches represented as a Match object.
290 *
291 */
292 public Collection<ChoiceHasNoIncoming.Match> getAllMatches(final Choice pC) {
293 return rawStreamAllMatches(new Object[]{pC}).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 pC the fixed value of pattern parameter c, or null if not bound.
303 * @return a stream of matches represented as a Match object.
304 *
305 */
306 public Stream<ChoiceHasNoIncoming.Match> streamAllMatches(final Choice pC) {
307 return rawStreamAllMatches(new Object[]{pC});
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 pC the fixed value of pattern parameter c, 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<ChoiceHasNoIncoming.Match> getOneArbitraryMatch(final Choice pC) {
318 return rawGetOneArbitraryMatch(new Object[]{pC});
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 pC the fixed value of pattern parameter c, 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 Choice pC) {
329 return rawHasMatch(new Object[]{pC});
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 pC the fixed value of pattern parameter c, or null if not bound.
335 * @return the number of pattern matches found.
336 *
337 */
338 public int countMatches(final Choice pC) {
339 return rawCountMatches(new Object[]{pC});
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 pC the fixed value of pattern parameter c, 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 Choice pC, final Consumer<? super ChoiceHasNoIncoming.Match> processor) {
351 return rawForOneArbitraryMatch(new Object[]{pC}, 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 pC the fixed value of pattern parameter c, or null if not bound.
359 * @return the (partial) match object.
360 *
361 */
362 public ChoiceHasNoIncoming.Match newMatch(final Choice pC) {
363 return ChoiceHasNoIncoming.Match.newMatch(pC);
364 }
365
366 /**
367 * Retrieve the set of values that occur in matches for c.
368 * @return the Set of all values or empty set if there are no matches
369 *
370 */
371 protected Stream<Choice> rawStreamAllValuesOfc(final Object[] parameters) {
372 return rawStreamAllValues(POSITION_C, parameters).map(Choice.class::cast);
373 }
374
375 /**
376 * Retrieve the set of values that occur in matches for c.
377 * @return the Set of all values or empty set if there are no matches
378 *
379 */
380 public Set<Choice> getAllValuesOfc() {
381 return rawStreamAllValuesOfc(emptyArray()).collect(Collectors.toSet());
382 }
383
384 /**
385 * Retrieve the set of values that occur in matches for c.
386 * @return the Set of all values or empty set if there are no matches
387 *
388 */
389 public Stream<Choice> streamAllValuesOfc() {
390 return rawStreamAllValuesOfc(emptyArray());
391 }
392
393 @Override
394 protected ChoiceHasNoIncoming.Match tupleToMatch(final Tuple t) {
395 try {
396 return ChoiceHasNoIncoming.Match.newMatch((Choice) t.get(POSITION_C));
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 ChoiceHasNoIncoming.Match arrayToMatch(final Object[] match) {
405 try {
406 return ChoiceHasNoIncoming.Match.newMatch((Choice) match[POSITION_C]);
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 ChoiceHasNoIncoming.Match arrayToMatchMutable(final Object[] match) {
415 try {
416 return ChoiceHasNoIncoming.Match.newMutableMatch((Choice) match[POSITION_C]);
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<ChoiceHasNoIncoming.Matcher> querySpecification() {
429 return ChoiceHasNoIncoming.instance();
430 }
431 }
432
433 private ChoiceHasNoIncoming() {
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 ChoiceHasNoIncoming instance() {
443 try{
444 return LazyHolder.INSTANCE;
445 } catch (ExceptionInInitializerError err) {
446 throw processInitializerError(err);
447 }
448 }
449
450 @Override
451 protected ChoiceHasNoIncoming.Matcher instantiate(final ViatraQueryEngine engine) {
452 return ChoiceHasNoIncoming.Matcher.on(engine);
453 }
454
455 @Override
456 public ChoiceHasNoIncoming.Matcher instantiate() {
457 return ChoiceHasNoIncoming.Matcher.create();
458 }
459
460 @Override
461 public ChoiceHasNoIncoming.Match newEmptyMatch() {
462 return ChoiceHasNoIncoming.Match.newEmptyMatch();
463 }
464
465 @Override
466 public ChoiceHasNoIncoming.Match newMatch(final Object... parameters) {
467 return ChoiceHasNoIncoming.Match.newMatch((ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Choice) parameters[0]);
468 }
469
470 /**
471 * Inner class allowing the singleton instance of {@link JvmGenericType: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.ChoiceHasNoIncoming (visibility: PUBLIC, simpleName: ChoiceHasNoIncoming, identifier: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.ChoiceHasNoIncoming, 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.ChoiceHasNoIncoming (visibility: PUBLIC, simpleName: ChoiceHasNoIncoming, identifier: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.ChoiceHasNoIncoming, 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 ChoiceHasNoIncoming INSTANCE = new ChoiceHasNoIncoming();
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 ChoiceHasNoIncoming.GeneratedPQuery INSTANCE = new GeneratedPQuery();
498
499 private final PParameter parameter_c = new PParameter("c", "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Choice", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("YakinduMetamodel", "Choice")), PParameterDirection.INOUT);
500
501 private final List<PParameter> parameters = Arrays.asList(parameter_c);
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.choiceHasNoIncoming";
510 }
511
512 @Override
513 public List<String> getParameterNames() {
514 return Arrays.asList("c");
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_c = body.getOrCreateVariableByName("c");
529 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
530 PVariable var___1_ = body.getOrCreateVariableByName("_<1>");
531 new TypeConstraint(body, Tuples.flatTupleOf(var_c), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Choice")));
532 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
533 new ExportedParameter(body, var_c, parameter_c)
534 ));
535 // neg find transition(_, _, c)
536 new NegativePatternCall(body, Tuples.flatTupleOf(var___0_, var___1_, var_c), 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("c")
545 }));
546 addAnnotation(annotation);
547 }
548 return bodies;
549 }
550 }
551}