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