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