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