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