aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedRegionDoesNotHaveMultipleRegions.java
diff options
context:
space:
mode:
authorLibravatar ArenBabikian <aren.babikian@mail.mcgill.ca>2019-02-16 15:45:14 -0500
committerLibravatar ArenBabikian <aren.babikian@mail.mcgill.ca>2019-02-16 15:45:14 -0500
commit1da40b0bf07319bdb2e9a89f8d7d6ecfbc638952 (patch)
tree65a3cd74ed278d8af013c0e8a8c4d6ba920c3192 /Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedRegionDoesNotHaveMultipleRegions.java
parentSet up #19 (diff)
downloadVIATRA-Generator-1da40b0bf07319bdb2e9a89f8d7d6ecfbc638952.tar.gz
VIATRA-Generator-1da40b0bf07319bdb2e9a89f8d7d6ecfbc638952.tar.zst
VIATRA-Generator-1da40b0bf07319bdb2e9a89f8d7d6ecfbc638952.zip
Integrate queries partially #19
Diffstat (limited to 'Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedRegionDoesNotHaveMultipleRegions.java')
-rw-r--r--Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedRegionDoesNotHaveMultipleRegions.java744
1 files changed, 744 insertions, 0 deletions
diff --git a/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedRegionDoesNotHaveMultipleRegions.java b/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedRegionDoesNotHaveMultipleRegions.java
new file mode 100644
index 00000000..28eecf9c
--- /dev/null
+++ b/Tests/ca.mcgill.ecse.dslreasoner.standalone.test/src-gen/ca/mcgill/ecse/dslreasoner/standalone/test/yakindu/queries/SynchronizedRegionDoesNotHaveMultipleRegions.java
@@ -0,0 +1,744 @@
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.Vertex;
8import ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.Child;
9import ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.HasMultipleRegions;
10import ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.Transition;
11import java.util.Arrays;
12import java.util.Collection;
13import java.util.LinkedHashSet;
14import java.util.List;
15import java.util.Objects;
16import java.util.Optional;
17import java.util.Set;
18import java.util.function.Consumer;
19import java.util.stream.Collectors;
20import java.util.stream.Stream;
21import org.apache.log4j.Logger;
22import org.eclipse.emf.ecore.EClass;
23import org.eclipse.viatra.query.runtime.api.IPatternMatch;
24import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
26import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
27import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
28import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
29import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
30import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
31import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
32import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
33import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
34import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
35import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
39import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
42import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
44import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
45import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
46
47/**
48 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
49 *
50 * <p>Original source:
51 * <code><pre>
52 * {@literal @}Constraint(severity="error", message="error", key = {s})
53 * pattern SynchronizedRegionDoesNotHaveMultipleRegions(s : Synchronization, v : Vertex) {
54 * find transition(_, v, s);
55 * find child(c,v);
56 * neg find hasMultipleRegions(c);
57 * } or {
58 * find transition(_, s, v);
59 * find child(c,v);
60 * neg find hasMultipleRegions(c);
61 * }
62 * </pre></code>
63 *
64 * @see Matcher
65 * @see Match
66 *
67 */
68@SuppressWarnings("all")
69public final class SynchronizedRegionDoesNotHaveMultipleRegions extends BaseGeneratedEMFQuerySpecification<SynchronizedRegionDoesNotHaveMultipleRegions.Matcher> {
70 /**
71 * Pattern-specific match representation of the ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedRegionDoesNotHaveMultipleRegions pattern,
72 * to be used in conjunction with {@link Matcher}.
73 *
74 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
75 * Each instance is a (possibly partial) substitution of pattern parameters,
76 * usable to represent a match of the pattern in the result of a query,
77 * or to specify the bound (fixed) input parameters when issuing a query.
78 *
79 * @see Matcher
80 *
81 */
82 public static abstract class Match extends BasePatternMatch {
83 private Synchronization fS;
84
85 private Vertex fV;
86
87 private static List<String> parameterNames = makeImmutableList("s", "v");
88
89 private Match(final Synchronization pS, final Vertex pV) {
90 this.fS = pS;
91 this.fV = pV;
92 }
93
94 @Override
95 public Object get(final String parameterName) {
96 if ("s".equals(parameterName)) return this.fS;
97 if ("v".equals(parameterName)) return this.fV;
98 return null;
99 }
100
101 public Synchronization getS() {
102 return this.fS;
103 }
104
105 public Vertex getV() {
106 return this.fV;
107 }
108
109 @Override
110 public boolean set(final String parameterName, final Object newValue) {
111 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
112 if ("s".equals(parameterName) ) {
113 this.fS = (Synchronization) newValue;
114 return true;
115 }
116 if ("v".equals(parameterName) ) {
117 this.fV = (Vertex) newValue;
118 return true;
119 }
120 return false;
121 }
122
123 public void setS(final Synchronization pS) {
124 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
125 this.fS = pS;
126 }
127
128 public void setV(final Vertex pV) {
129 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
130 this.fV = pV;
131 }
132
133 @Override
134 public String patternName() {
135 return "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedRegionDoesNotHaveMultipleRegions";
136 }
137
138 @Override
139 public List<String> parameterNames() {
140 return SynchronizedRegionDoesNotHaveMultipleRegions.Match.parameterNames;
141 }
142
143 @Override
144 public Object[] toArray() {
145 return new Object[]{fS, fV};
146 }
147
148 @Override
149 public SynchronizedRegionDoesNotHaveMultipleRegions.Match toImmutable() {
150 return isMutable() ? newMatch(fS, fV) : this;
151 }
152
153 @Override
154 public String prettyPrint() {
155 StringBuilder result = new StringBuilder();
156 result.append("\"s\"=" + prettyPrintValue(fS) + ", ");
157 result.append("\"v\"=" + prettyPrintValue(fV));
158 return result.toString();
159 }
160
161 @Override
162 public int hashCode() {
163 return Objects.hash(fS, fV);
164 }
165
166 @Override
167 public boolean equals(final Object obj) {
168 if (this == obj)
169 return true;
170 if (obj == null) {
171 return false;
172 }
173 if ((obj instanceof SynchronizedRegionDoesNotHaveMultipleRegions.Match)) {
174 SynchronizedRegionDoesNotHaveMultipleRegions.Match other = (SynchronizedRegionDoesNotHaveMultipleRegions.Match) obj;
175 return Objects.equals(fS, other.fS) && Objects.equals(fV, other.fV);
176 } else {
177 // this should be infrequent
178 if (!(obj instanceof IPatternMatch)) {
179 return false;
180 }
181 IPatternMatch otherSig = (IPatternMatch) obj;
182 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
183 }
184 }
185
186 @Override
187 public SynchronizedRegionDoesNotHaveMultipleRegions specification() {
188 return SynchronizedRegionDoesNotHaveMultipleRegions.instance();
189 }
190
191 /**
192 * Returns an empty, mutable match.
193 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
194 *
195 * @return the empty match.
196 *
197 */
198 public static SynchronizedRegionDoesNotHaveMultipleRegions.Match newEmptyMatch() {
199 return new Mutable(null, null);
200 }
201
202 /**
203 * Returns a mutable (partial) match.
204 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
205 *
206 * @param pS the fixed value of pattern parameter s, or null if not bound.
207 * @param pV the fixed value of pattern parameter v, or null if not bound.
208 * @return the new, mutable (partial) match object.
209 *
210 */
211 public static SynchronizedRegionDoesNotHaveMultipleRegions.Match newMutableMatch(final Synchronization pS, final Vertex pV) {
212 return new Mutable(pS, pV);
213 }
214
215 /**
216 * Returns a new (partial) match.
217 * This can be used e.g. to call the matcher with a partial match.
218 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
219 * @param pS the fixed value of pattern parameter s, or null if not bound.
220 * @param pV the fixed value of pattern parameter v, or null if not bound.
221 * @return the (partial) match object.
222 *
223 */
224 public static SynchronizedRegionDoesNotHaveMultipleRegions.Match newMatch(final Synchronization pS, final Vertex pV) {
225 return new Immutable(pS, pV);
226 }
227
228 private static final class Mutable extends SynchronizedRegionDoesNotHaveMultipleRegions.Match {
229 Mutable(final Synchronization pS, final Vertex pV) {
230 super(pS, pV);
231 }
232
233 @Override
234 public boolean isMutable() {
235 return true;
236 }
237 }
238
239 private static final class Immutable extends SynchronizedRegionDoesNotHaveMultipleRegions.Match {
240 Immutable(final Synchronization pS, final Vertex pV) {
241 super(pS, pV);
242 }
243
244 @Override
245 public boolean isMutable() {
246 return false;
247 }
248 }
249 }
250
251 /**
252 * Generated pattern matcher API of the ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedRegionDoesNotHaveMultipleRegions pattern,
253 * providing pattern-specific query methods.
254 *
255 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
256 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
257 *
258 * <p>Matches of the pattern will be represented as {@link Match}.
259 *
260 * <p>Original source:
261 * <code><pre>
262 * {@literal @}Constraint(severity="error", message="error", key = {s})
263 * pattern SynchronizedRegionDoesNotHaveMultipleRegions(s : Synchronization, v : Vertex) {
264 * find transition(_, v, s);
265 * find child(c,v);
266 * neg find hasMultipleRegions(c);
267 * } or {
268 * find transition(_, s, v);
269 * find child(c,v);
270 * neg find hasMultipleRegions(c);
271 * }
272 * </pre></code>
273 *
274 * @see Match
275 * @see SynchronizedRegionDoesNotHaveMultipleRegions
276 *
277 */
278 public static class Matcher extends BaseMatcher<SynchronizedRegionDoesNotHaveMultipleRegions.Match> {
279 /**
280 * Initializes the pattern matcher within an existing VIATRA Query engine.
281 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
282 *
283 * @param engine the existing VIATRA Query engine in which this matcher will be created.
284 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
285 *
286 */
287 public static SynchronizedRegionDoesNotHaveMultipleRegions.Matcher on(final ViatraQueryEngine engine) {
288 // check if matcher already exists
289 Matcher matcher = engine.getExistingMatcher(querySpecification());
290 if (matcher == null) {
291 matcher = (Matcher)engine.getMatcher(querySpecification());
292 }
293 return matcher;
294 }
295
296 /**
297 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
298 * @return an initialized matcher
299 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
300 *
301 */
302 public static SynchronizedRegionDoesNotHaveMultipleRegions.Matcher create() {
303 return new Matcher();
304 }
305
306 private final static int POSITION_S = 0;
307
308 private final static int POSITION_V = 1;
309
310 private final static Logger LOGGER = ViatraQueryLoggingUtil.getLogger(SynchronizedRegionDoesNotHaveMultipleRegions.Matcher.class);
311
312 /**
313 * Initializes the pattern matcher within an existing VIATRA Query engine.
314 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
315 *
316 * @param engine the existing VIATRA Query engine in which this matcher will be created.
317 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
318 *
319 */
320 private Matcher() {
321 super(querySpecification());
322 }
323
324 /**
325 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
326 * @param pS the fixed value of pattern parameter s, or null if not bound.
327 * @param pV the fixed value of pattern parameter v, or null if not bound.
328 * @return matches represented as a Match object.
329 *
330 */
331 public Collection<SynchronizedRegionDoesNotHaveMultipleRegions.Match> getAllMatches(final Synchronization pS, final Vertex pV) {
332 return rawStreamAllMatches(new Object[]{pS, pV}).collect(Collectors.toSet());
333 }
334
335 /**
336 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
337 * </p>
338 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
339 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
340 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
341 * @param pS the fixed value of pattern parameter s, or null if not bound.
342 * @param pV the fixed value of pattern parameter v, or null if not bound.
343 * @return a stream of matches represented as a Match object.
344 *
345 */
346 public Stream<SynchronizedRegionDoesNotHaveMultipleRegions.Match> streamAllMatches(final Synchronization pS, final Vertex pV) {
347 return rawStreamAllMatches(new Object[]{pS, pV});
348 }
349
350 /**
351 * Returns 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 pS the fixed value of pattern parameter s, or null if not bound.
354 * @param pV the fixed value of pattern parameter v, or null if not bound.
355 * @return a match represented as a Match object, or null if no match is found.
356 *
357 */
358 public Optional<SynchronizedRegionDoesNotHaveMultipleRegions.Match> getOneArbitraryMatch(final Synchronization pS, final Vertex pV) {
359 return rawGetOneArbitraryMatch(new Object[]{pS, pV});
360 }
361
362 /**
363 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
364 * under any possible substitution of the unspecified parameters (if any).
365 * @param pS the fixed value of pattern parameter s, or null if not bound.
366 * @param pV the fixed value of pattern parameter v, or null if not bound.
367 * @return true if the input is a valid (partial) match of the pattern.
368 *
369 */
370 public boolean hasMatch(final Synchronization pS, final Vertex pV) {
371 return rawHasMatch(new Object[]{pS, pV});
372 }
373
374 /**
375 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
376 * @param pS the fixed value of pattern parameter s, or null if not bound.
377 * @param pV the fixed value of pattern parameter v, or null if not bound.
378 * @return the number of pattern matches found.
379 *
380 */
381 public int countMatches(final Synchronization pS, final Vertex pV) {
382 return rawCountMatches(new Object[]{pS, pV});
383 }
384
385 /**
386 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
387 * Neither determinism nor randomness of selection is guaranteed.
388 * @param pS the fixed value of pattern parameter s, or null if not bound.
389 * @param pV the fixed value of pattern parameter v, or null if not bound.
390 * @param processor the action that will process the selected match.
391 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
392 *
393 */
394 public boolean forOneArbitraryMatch(final Synchronization pS, final Vertex pV, final Consumer<? super SynchronizedRegionDoesNotHaveMultipleRegions.Match> processor) {
395 return rawForOneArbitraryMatch(new Object[]{pS, pV}, processor);
396 }
397
398 /**
399 * Returns a new (partial) match.
400 * This can be used e.g. to call the matcher with a partial match.
401 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
402 * @param pS the fixed value of pattern parameter s, or null if not bound.
403 * @param pV the fixed value of pattern parameter v, or null if not bound.
404 * @return the (partial) match object.
405 *
406 */
407 public SynchronizedRegionDoesNotHaveMultipleRegions.Match newMatch(final Synchronization pS, final Vertex pV) {
408 return SynchronizedRegionDoesNotHaveMultipleRegions.Match.newMatch(pS, pV);
409 }
410
411 /**
412 * Retrieve the set of values that occur in matches for s.
413 * @return the Set of all values or empty set if there are no matches
414 *
415 */
416 protected Stream<Synchronization> rawStreamAllValuesOfs(final Object[] parameters) {
417 return rawStreamAllValues(POSITION_S, parameters).map(Synchronization.class::cast);
418 }
419
420 /**
421 * Retrieve the set of values that occur in matches for s.
422 * @return the Set of all values or empty set if there are no matches
423 *
424 */
425 public Set<Synchronization> getAllValuesOfs() {
426 return rawStreamAllValuesOfs(emptyArray()).collect(Collectors.toSet());
427 }
428
429 /**
430 * Retrieve the set of values that occur in matches for s.
431 * @return the Set of all values or empty set if there are no matches
432 *
433 */
434 public Stream<Synchronization> streamAllValuesOfs() {
435 return rawStreamAllValuesOfs(emptyArray());
436 }
437
438 /**
439 * Retrieve the set of values that occur in matches for s.
440 * </p>
441 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
442 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
443 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
444 *
445 * @return the Stream of all values or empty set if there are no matches
446 *
447 */
448 public Stream<Synchronization> streamAllValuesOfs(final SynchronizedRegionDoesNotHaveMultipleRegions.Match partialMatch) {
449 return rawStreamAllValuesOfs(partialMatch.toArray());
450 }
451
452 /**
453 * Retrieve the set of values that occur in matches for s.
454 * </p>
455 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
456 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
457 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
458 *
459 * @return the Stream of all values or empty set if there are no matches
460 *
461 */
462 public Stream<Synchronization> streamAllValuesOfs(final Vertex pV) {
463 return rawStreamAllValuesOfs(new Object[]{null, pV});
464 }
465
466 /**
467 * Retrieve the set of values that occur in matches for s.
468 * @return the Set of all values or empty set if there are no matches
469 *
470 */
471 public Set<Synchronization> getAllValuesOfs(final SynchronizedRegionDoesNotHaveMultipleRegions.Match partialMatch) {
472 return rawStreamAllValuesOfs(partialMatch.toArray()).collect(Collectors.toSet());
473 }
474
475 /**
476 * Retrieve the set of values that occur in matches for s.
477 * @return the Set of all values or empty set if there are no matches
478 *
479 */
480 public Set<Synchronization> getAllValuesOfs(final Vertex pV) {
481 return rawStreamAllValuesOfs(new Object[]{null, pV}).collect(Collectors.toSet());
482 }
483
484 /**
485 * Retrieve the set of values that occur in matches for v.
486 * @return the Set of all values or empty set if there are no matches
487 *
488 */
489 protected Stream<Vertex> rawStreamAllValuesOfv(final Object[] parameters) {
490 return rawStreamAllValues(POSITION_V, parameters).map(Vertex.class::cast);
491 }
492
493 /**
494 * Retrieve the set of values that occur in matches for v.
495 * @return the Set of all values or empty set if there are no matches
496 *
497 */
498 public Set<Vertex> getAllValuesOfv() {
499 return rawStreamAllValuesOfv(emptyArray()).collect(Collectors.toSet());
500 }
501
502 /**
503 * Retrieve the set of values that occur in matches for v.
504 * @return the Set of all values or empty set if there are no matches
505 *
506 */
507 public Stream<Vertex> streamAllValuesOfv() {
508 return rawStreamAllValuesOfv(emptyArray());
509 }
510
511 /**
512 * Retrieve the set of values that occur in matches for v.
513 * </p>
514 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
515 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
516 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
517 *
518 * @return the Stream of all values or empty set if there are no matches
519 *
520 */
521 public Stream<Vertex> streamAllValuesOfv(final SynchronizedRegionDoesNotHaveMultipleRegions.Match partialMatch) {
522 return rawStreamAllValuesOfv(partialMatch.toArray());
523 }
524
525 /**
526 * Retrieve the set of values that occur in matches for v.
527 * </p>
528 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
529 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
530 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
531 *
532 * @return the Stream of all values or empty set if there are no matches
533 *
534 */
535 public Stream<Vertex> streamAllValuesOfv(final Synchronization pS) {
536 return rawStreamAllValuesOfv(new Object[]{pS, null});
537 }
538
539 /**
540 * Retrieve the set of values that occur in matches for v.
541 * @return the Set of all values or empty set if there are no matches
542 *
543 */
544 public Set<Vertex> getAllValuesOfv(final SynchronizedRegionDoesNotHaveMultipleRegions.Match partialMatch) {
545 return rawStreamAllValuesOfv(partialMatch.toArray()).collect(Collectors.toSet());
546 }
547
548 /**
549 * Retrieve the set of values that occur in matches for v.
550 * @return the Set of all values or empty set if there are no matches
551 *
552 */
553 public Set<Vertex> getAllValuesOfv(final Synchronization pS) {
554 return rawStreamAllValuesOfv(new Object[]{pS, null}).collect(Collectors.toSet());
555 }
556
557 @Override
558 protected SynchronizedRegionDoesNotHaveMultipleRegions.Match tupleToMatch(final Tuple t) {
559 try {
560 return SynchronizedRegionDoesNotHaveMultipleRegions.Match.newMatch((Synchronization) t.get(POSITION_S), (Vertex) t.get(POSITION_V));
561 } catch(ClassCastException e) {
562 LOGGER.error("Element(s) in tuple not properly typed!",e);
563 return null;
564 }
565 }
566
567 @Override
568 protected SynchronizedRegionDoesNotHaveMultipleRegions.Match arrayToMatch(final Object[] match) {
569 try {
570 return SynchronizedRegionDoesNotHaveMultipleRegions.Match.newMatch((Synchronization) match[POSITION_S], (Vertex) match[POSITION_V]);
571 } catch(ClassCastException e) {
572 LOGGER.error("Element(s) in array not properly typed!",e);
573 return null;
574 }
575 }
576
577 @Override
578 protected SynchronizedRegionDoesNotHaveMultipleRegions.Match arrayToMatchMutable(final Object[] match) {
579 try {
580 return SynchronizedRegionDoesNotHaveMultipleRegions.Match.newMutableMatch((Synchronization) match[POSITION_S], (Vertex) match[POSITION_V]);
581 } catch(ClassCastException e) {
582 LOGGER.error("Element(s) in array not properly typed!",e);
583 return null;
584 }
585 }
586
587 /**
588 * @return the singleton instance of the query specification of this pattern
589 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
590 *
591 */
592 public static IQuerySpecification<SynchronizedRegionDoesNotHaveMultipleRegions.Matcher> querySpecification() {
593 return SynchronizedRegionDoesNotHaveMultipleRegions.instance();
594 }
595 }
596
597 private SynchronizedRegionDoesNotHaveMultipleRegions() {
598 super(GeneratedPQuery.INSTANCE);
599 }
600
601 /**
602 * @return the singleton instance of the query specification
603 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
604 *
605 */
606 public static SynchronizedRegionDoesNotHaveMultipleRegions instance() {
607 try{
608 return LazyHolder.INSTANCE;
609 } catch (ExceptionInInitializerError err) {
610 throw processInitializerError(err);
611 }
612 }
613
614 @Override
615 protected SynchronizedRegionDoesNotHaveMultipleRegions.Matcher instantiate(final ViatraQueryEngine engine) {
616 return SynchronizedRegionDoesNotHaveMultipleRegions.Matcher.on(engine);
617 }
618
619 @Override
620 public SynchronizedRegionDoesNotHaveMultipleRegions.Matcher instantiate() {
621 return SynchronizedRegionDoesNotHaveMultipleRegions.Matcher.create();
622 }
623
624 @Override
625 public SynchronizedRegionDoesNotHaveMultipleRegions.Match newEmptyMatch() {
626 return SynchronizedRegionDoesNotHaveMultipleRegions.Match.newEmptyMatch();
627 }
628
629 @Override
630 public SynchronizedRegionDoesNotHaveMultipleRegions.Match newMatch(final Object... parameters) {
631 return SynchronizedRegionDoesNotHaveMultipleRegions.Match.newMatch((ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Synchronization) parameters[0], (ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Vertex) parameters[1]);
632 }
633
634 /**
635 * Inner class allowing the singleton instance of {@link JvmGenericType: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedRegionDoesNotHaveMultipleRegions (visibility: PUBLIC, simpleName: SynchronizedRegionDoesNotHaveMultipleRegions, identifier: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedRegionDoesNotHaveMultipleRegions, 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
636 * <b>not</b> at the class load time of the outer class,
637 * but rather at the first call to {@link JvmGenericType: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedRegionDoesNotHaveMultipleRegions (visibility: PUBLIC, simpleName: SynchronizedRegionDoesNotHaveMultipleRegions, identifier: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedRegionDoesNotHaveMultipleRegions, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
638 *
639 * <p> This workaround is required e.g. to support recursion.
640 *
641 */
642 private static class LazyHolder {
643 private final static SynchronizedRegionDoesNotHaveMultipleRegions INSTANCE = new SynchronizedRegionDoesNotHaveMultipleRegions();
644
645 /**
646 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
647 * This initialization order is required to support indirect recursion.
648 *
649 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
650 *
651 */
652 private final static Object STATIC_INITIALIZER = ensureInitialized();
653
654 public static Object ensureInitialized() {
655 INSTANCE.ensureInitializedInternal();
656 return null;
657 }
658 }
659
660 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
661 private final static SynchronizedRegionDoesNotHaveMultipleRegions.GeneratedPQuery INSTANCE = new GeneratedPQuery();
662
663 private final PParameter parameter_s = new PParameter("s", "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Synchronization", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("YakinduMetamodel", "Synchronization")), PParameterDirection.INOUT);
664
665 private final PParameter parameter_v = new PParameter("v", "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.Vertex", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("YakinduMetamodel", "Vertex")), PParameterDirection.INOUT);
666
667 private final List<PParameter> parameters = Arrays.asList(parameter_s, parameter_v);
668
669 private GeneratedPQuery() {
670 super(PVisibility.PUBLIC);
671 }
672
673 @Override
674 public String getFullyQualifiedName() {
675 return "ca.mcgill.ecse.dslreasoner.standalone.test.yakindu.queries.SynchronizedRegionDoesNotHaveMultipleRegions";
676 }
677
678 @Override
679 public List<String> getParameterNames() {
680 return Arrays.asList("s","v");
681 }
682
683 @Override
684 public List<PParameter> getParameters() {
685 return parameters;
686 }
687
688 @Override
689 public Set<PBody> doGetContainedBodies() {
690 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
691 Set<PBody> bodies = new LinkedHashSet<>();
692 {
693 PBody body = new PBody(this);
694 PVariable var_s = body.getOrCreateVariableByName("s");
695 PVariable var_v = body.getOrCreateVariableByName("v");
696 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
697 PVariable var_c = body.getOrCreateVariableByName("c");
698 new TypeConstraint(body, Tuples.flatTupleOf(var_s), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Synchronization")));
699 new TypeConstraint(body, Tuples.flatTupleOf(var_v), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Vertex")));
700 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
701 new ExportedParameter(body, var_s, parameter_s),
702 new ExportedParameter(body, var_v, parameter_v)
703 ));
704 // find transition(_, v, s)
705 new PositivePatternCall(body, Tuples.flatTupleOf(var___0_, var_v, var_s), Transition.instance().getInternalQueryRepresentation());
706 // find child(c,v)
707 new PositivePatternCall(body, Tuples.flatTupleOf(var_c, var_v), Child.instance().getInternalQueryRepresentation());
708 // neg find hasMultipleRegions(c)
709 new NegativePatternCall(body, Tuples.flatTupleOf(var_c), HasMultipleRegions.instance().getInternalQueryRepresentation());
710 bodies.add(body);
711 }
712 {
713 PBody body = new PBody(this);
714 PVariable var_s = body.getOrCreateVariableByName("s");
715 PVariable var_v = body.getOrCreateVariableByName("v");
716 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
717 PVariable var_c = body.getOrCreateVariableByName("c");
718 new TypeConstraint(body, Tuples.flatTupleOf(var_s), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Synchronization")));
719 new TypeConstraint(body, Tuples.flatTupleOf(var_v), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("YakinduMetamodel", "Vertex")));
720 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
721 new ExportedParameter(body, var_s, parameter_s),
722 new ExportedParameter(body, var_v, parameter_v)
723 ));
724 // find transition(_, s, v)
725 new PositivePatternCall(body, Tuples.flatTupleOf(var___0_, var_s, var_v), Transition.instance().getInternalQueryRepresentation());
726 // find child(c,v)
727 new PositivePatternCall(body, Tuples.flatTupleOf(var_c, var_v), Child.instance().getInternalQueryRepresentation());
728 // neg find hasMultipleRegions(c)
729 new NegativePatternCall(body, Tuples.flatTupleOf(var_c), HasMultipleRegions.instance().getInternalQueryRepresentation());
730 bodies.add(body);
731 }
732 {
733 PAnnotation annotation = new PAnnotation("Constraint");
734 annotation.addAttribute("severity", "error");
735 annotation.addAttribute("message", "error");
736 annotation.addAttribute("key", Arrays.asList(new Object[] {
737 new ParameterReference("s")
738 }));
739 addAnnotation(annotation);
740 }
741 return bodies;
742 }
743 }
744}