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