diff options
Diffstat (limited to 'Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java')
-rw-r--r-- | Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java | 601 |
1 files changed, 601 insertions, 0 deletions
diff --git a/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java new file mode 100644 index 00000000..e5e8827c --- /dev/null +++ b/Domains/ca.mcgill.rtgmrt.example.modes3/vql-gen/modes3/queries/TooManyInputsOfSegment.java | |||
@@ -0,0 +1,601 @@ | |||
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.queries.Output; | ||
18 | import modes3.queries.Turnout; | ||
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.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.ExportedParameter; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Inequality; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
44 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
45 | |||
46 | /** | ||
47 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
48 | * | ||
49 | * <p>Original source: | ||
50 | * <code><pre> | ||
51 | * //{@literal @}Constraint(message = "noInputOfSegment", severity = "error", key = { S }) | ||
52 | * //pattern noInputOfSegment(S : Segment) { | ||
53 | * // neg find turnout(S); | ||
54 | * // neg find output(_, S); | ||
55 | * //} | ||
56 | * | ||
57 | * {@literal @}Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S }) | ||
58 | * pattern tooManyInputsOfSegment(S : Segment) { | ||
59 | * neg find turnout(S); | ||
60 | * find output(I1, S); | ||
61 | * find output(I2, S); | ||
62 | * find output(I3, S); | ||
63 | * I1 != I2; | ||
64 | * I1 != I3; | ||
65 | * I2 != I3; | ||
66 | * } | ||
67 | * </pre></code> | ||
68 | * | ||
69 | * @see Matcher | ||
70 | * @see Match | ||
71 | * | ||
72 | */ | ||
73 | @SuppressWarnings("all") | ||
74 | public final class TooManyInputsOfSegment extends BaseGeneratedEMFQuerySpecification<TooManyInputsOfSegment.Matcher> { | ||
75 | /** | ||
76 | * Pattern-specific match representation of the modes3.queries.tooManyInputsOfSegment pattern, | ||
77 | * to be used in conjunction with {@link Matcher}. | ||
78 | * | ||
79 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
80 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
81 | * usable to represent a match of the pattern in the result of a query, | ||
82 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
83 | * | ||
84 | * @see Matcher | ||
85 | * | ||
86 | */ | ||
87 | public static abstract class Match extends BasePatternMatch { | ||
88 | private Segment fS; | ||
89 | |||
90 | private static List<String> parameterNames = makeImmutableList("S"); | ||
91 | |||
92 | private Match(final Segment pS) { | ||
93 | this.fS = pS; | ||
94 | } | ||
95 | |||
96 | @Override | ||
97 | public Object get(final String parameterName) { | ||
98 | switch(parameterName) { | ||
99 | case "S": return this.fS; | ||
100 | default: return null; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | @Override | ||
105 | public Object get(final int index) { | ||
106 | switch(index) { | ||
107 | case 0: return this.fS; | ||
108 | default: return null; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | public Segment getS() { | ||
113 | return this.fS; | ||
114 | } | ||
115 | |||
116 | @Override | ||
117 | public boolean set(final String parameterName, final Object newValue) { | ||
118 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
119 | if ("S".equals(parameterName) ) { | ||
120 | this.fS = (Segment) newValue; | ||
121 | return true; | ||
122 | } | ||
123 | return false; | ||
124 | } | ||
125 | |||
126 | public void setS(final Segment pS) { | ||
127 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
128 | this.fS = pS; | ||
129 | } | ||
130 | |||
131 | @Override | ||
132 | public String patternName() { | ||
133 | return "modes3.queries.tooManyInputsOfSegment"; | ||
134 | } | ||
135 | |||
136 | @Override | ||
137 | public List<String> parameterNames() { | ||
138 | return TooManyInputsOfSegment.Match.parameterNames; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public Object[] toArray() { | ||
143 | return new Object[]{fS}; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public TooManyInputsOfSegment.Match toImmutable() { | ||
148 | return isMutable() ? newMatch(fS) : this; | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public String prettyPrint() { | ||
153 | StringBuilder result = new StringBuilder(); | ||
154 | result.append("\"S\"=" + prettyPrintValue(fS)); | ||
155 | return result.toString(); | ||
156 | } | ||
157 | |||
158 | @Override | ||
159 | public int hashCode() { | ||
160 | return Objects.hash(fS); | ||
161 | } | ||
162 | |||
163 | @Override | ||
164 | public boolean equals(final Object obj) { | ||
165 | if (this == obj) | ||
166 | return true; | ||
167 | if (obj == null) { | ||
168 | return false; | ||
169 | } | ||
170 | if ((obj instanceof TooManyInputsOfSegment.Match)) { | ||
171 | TooManyInputsOfSegment.Match other = (TooManyInputsOfSegment.Match) obj; | ||
172 | return Objects.equals(fS, other.fS); | ||
173 | } else { | ||
174 | // this should be infrequent | ||
175 | if (!(obj instanceof IPatternMatch)) { | ||
176 | return false; | ||
177 | } | ||
178 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
179 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | @Override | ||
184 | public TooManyInputsOfSegment specification() { | ||
185 | return TooManyInputsOfSegment.instance(); | ||
186 | } | ||
187 | |||
188 | /** | ||
189 | * Returns an empty, mutable match. | ||
190 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
191 | * | ||
192 | * @return the empty match. | ||
193 | * | ||
194 | */ | ||
195 | public static TooManyInputsOfSegment.Match newEmptyMatch() { | ||
196 | return new Mutable(null); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * Returns a mutable (partial) match. | ||
201 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
202 | * | ||
203 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
204 | * @return the new, mutable (partial) match object. | ||
205 | * | ||
206 | */ | ||
207 | public static TooManyInputsOfSegment.Match newMutableMatch(final Segment pS) { | ||
208 | return new Mutable(pS); | ||
209 | } | ||
210 | |||
211 | /** | ||
212 | * Returns a new (partial) match. | ||
213 | * This can be used e.g. to call the matcher with a partial match. | ||
214 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
215 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
216 | * @return the (partial) match object. | ||
217 | * | ||
218 | */ | ||
219 | public static TooManyInputsOfSegment.Match newMatch(final Segment pS) { | ||
220 | return new Immutable(pS); | ||
221 | } | ||
222 | |||
223 | private static final class Mutable extends TooManyInputsOfSegment.Match { | ||
224 | Mutable(final Segment pS) { | ||
225 | super(pS); | ||
226 | } | ||
227 | |||
228 | @Override | ||
229 | public boolean isMutable() { | ||
230 | return true; | ||
231 | } | ||
232 | } | ||
233 | |||
234 | private static final class Immutable extends TooManyInputsOfSegment.Match { | ||
235 | Immutable(final Segment pS) { | ||
236 | super(pS); | ||
237 | } | ||
238 | |||
239 | @Override | ||
240 | public boolean isMutable() { | ||
241 | return false; | ||
242 | } | ||
243 | } | ||
244 | } | ||
245 | |||
246 | /** | ||
247 | * Generated pattern matcher API of the modes3.queries.tooManyInputsOfSegment 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 = "noInputOfSegment", severity = "error", key = { S }) | ||
258 | * //pattern noInputOfSegment(S : Segment) { | ||
259 | * // neg find turnout(S); | ||
260 | * // neg find output(_, S); | ||
261 | * //} | ||
262 | * | ||
263 | * {@literal @}Constraint(message = "tooManyInputsOfSegment", severity = "error", key = { S }) | ||
264 | * pattern tooManyInputsOfSegment(S : Segment) { | ||
265 | * neg find turnout(S); | ||
266 | * find output(I1, S); | ||
267 | * find output(I2, S); | ||
268 | * find output(I3, S); | ||
269 | * I1 != I2; | ||
270 | * I1 != I3; | ||
271 | * I2 != I3; | ||
272 | * } | ||
273 | * </pre></code> | ||
274 | * | ||
275 | * @see Match | ||
276 | * @see TooManyInputsOfSegment | ||
277 | * | ||
278 | */ | ||
279 | public static class Matcher extends BaseMatcher<TooManyInputsOfSegment.Match> { | ||
280 | /** | ||
281 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
282 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
283 | * | ||
284 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
285 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
286 | * | ||
287 | */ | ||
288 | public static TooManyInputsOfSegment.Matcher on(final ViatraQueryEngine engine) { | ||
289 | // check if matcher already exists | ||
290 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
291 | if (matcher == null) { | ||
292 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
293 | } | ||
294 | return matcher; | ||
295 | } | ||
296 | |||
297 | /** | ||
298 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
299 | * @return an initialized matcher | ||
300 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
301 | * | ||
302 | */ | ||
303 | public static TooManyInputsOfSegment.Matcher create() { | ||
304 | return new Matcher(); | ||
305 | } | ||
306 | |||
307 | private static final int POSITION_S = 0; | ||
308 | |||
309 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(TooManyInputsOfSegment.Matcher.class); | ||
310 | |||
311 | /** | ||
312 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
313 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
314 | * | ||
315 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
316 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
317 | * | ||
318 | */ | ||
319 | private Matcher() { | ||
320 | super(querySpecification()); | ||
321 | } | ||
322 | |||
323 | /** | ||
324 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
325 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
326 | * @return matches represented as a Match object. | ||
327 | * | ||
328 | */ | ||
329 | public Collection<TooManyInputsOfSegment.Match> getAllMatches(final Segment pS) { | ||
330 | return rawStreamAllMatches(new Object[]{pS}).collect(Collectors.toSet()); | ||
331 | } | ||
332 | |||
333 | /** | ||
334 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
335 | * </p> | ||
336 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
337 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
338 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
339 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
340 | * @return a stream of matches represented as a Match object. | ||
341 | * | ||
342 | */ | ||
343 | public Stream<TooManyInputsOfSegment.Match> streamAllMatches(final Segment pS) { | ||
344 | return rawStreamAllMatches(new Object[]{pS}); | ||
345 | } | ||
346 | |||
347 | /** | ||
348 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
349 | * Neither determinism nor randomness of selection is guaranteed. | ||
350 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
351 | * @return a match represented as a Match object, or null if no match is found. | ||
352 | * | ||
353 | */ | ||
354 | public Optional<TooManyInputsOfSegment.Match> getOneArbitraryMatch(final Segment pS) { | ||
355 | return rawGetOneArbitraryMatch(new Object[]{pS}); | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
360 | * under any possible substitution of the unspecified parameters (if any). | ||
361 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
362 | * @return true if the input is a valid (partial) match of the pattern. | ||
363 | * | ||
364 | */ | ||
365 | public boolean hasMatch(final Segment pS) { | ||
366 | return rawHasMatch(new Object[]{pS}); | ||
367 | } | ||
368 | |||
369 | /** | ||
370 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
371 | * @param pS the fixed value of pattern parameter S, or null if not bound. | ||
372 | * @return the number of pattern matches found. | ||
373 | * | ||
374 | */ | ||
375 | public int countMatches(final Segment pS) { | ||
376 | return rawCountMatches(new Object[]{pS}); | ||
377 | } | ||
378 | |||
379 | /** | ||
380 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
381 | * Neither determinism nor randomness of selection is guaranteed. | ||
382 | * @param pS the fixed value of pattern parameter S, 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 Segment pS, final Consumer<? super TooManyInputsOfSegment.Match> processor) { | ||
388 | return rawForOneArbitraryMatch(new Object[]{pS}, 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 pS the fixed value of pattern parameter S, or null if not bound. | ||
396 | * @return the (partial) match object. | ||
397 | * | ||
398 | */ | ||
399 | public TooManyInputsOfSegment.Match newMatch(final Segment pS) { | ||
400 | return TooManyInputsOfSegment.Match.newMatch(pS); | ||
401 | } | ||
402 | |||
403 | /** | ||
404 | * Retrieve the set of values that occur in matches for S. | ||
405 | * @return the Set of all values or empty set if there are no matches | ||
406 | * | ||
407 | */ | ||
408 | protected Stream<Segment> rawStreamAllValuesOfS(final Object[] parameters) { | ||
409 | return rawStreamAllValues(POSITION_S, parameters).map(Segment.class::cast); | ||
410 | } | ||
411 | |||
412 | /** | ||
413 | * Retrieve the set of values that occur in matches for S. | ||
414 | * @return the Set of all values or empty set if there are no matches | ||
415 | * | ||
416 | */ | ||
417 | public Set<Segment> getAllValuesOfS() { | ||
418 | return rawStreamAllValuesOfS(emptyArray()).collect(Collectors.toSet()); | ||
419 | } | ||
420 | |||
421 | /** | ||
422 | * Retrieve the set of values that occur in matches for S. | ||
423 | * @return the Set of all values or empty set if there are no matches | ||
424 | * | ||
425 | */ | ||
426 | public Stream<Segment> streamAllValuesOfS() { | ||
427 | return rawStreamAllValuesOfS(emptyArray()); | ||
428 | } | ||
429 | |||
430 | @Override | ||
431 | protected TooManyInputsOfSegment.Match tupleToMatch(final Tuple t) { | ||
432 | try { | ||
433 | return TooManyInputsOfSegment.Match.newMatch((Segment) t.get(POSITION_S)); | ||
434 | } catch(ClassCastException e) { | ||
435 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
436 | return null; | ||
437 | } | ||
438 | } | ||
439 | |||
440 | @Override | ||
441 | protected TooManyInputsOfSegment.Match arrayToMatch(final Object[] match) { | ||
442 | try { | ||
443 | return TooManyInputsOfSegment.Match.newMatch((Segment) match[POSITION_S]); | ||
444 | } catch(ClassCastException e) { | ||
445 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
446 | return null; | ||
447 | } | ||
448 | } | ||
449 | |||
450 | @Override | ||
451 | protected TooManyInputsOfSegment.Match arrayToMatchMutable(final Object[] match) { | ||
452 | try { | ||
453 | return TooManyInputsOfSegment.Match.newMutableMatch((Segment) match[POSITION_S]); | ||
454 | } catch(ClassCastException e) { | ||
455 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
456 | return null; | ||
457 | } | ||
458 | } | ||
459 | |||
460 | /** | ||
461 | * @return the singleton instance of the query specification of this pattern | ||
462 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
463 | * | ||
464 | */ | ||
465 | public static IQuerySpecification<TooManyInputsOfSegment.Matcher> querySpecification() { | ||
466 | return TooManyInputsOfSegment.instance(); | ||
467 | } | ||
468 | } | ||
469 | |||
470 | private TooManyInputsOfSegment() { | ||
471 | super(GeneratedPQuery.INSTANCE); | ||
472 | } | ||
473 | |||
474 | /** | ||
475 | * @return the singleton instance of the query specification | ||
476 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
477 | * | ||
478 | */ | ||
479 | public static TooManyInputsOfSegment instance() { | ||
480 | try{ | ||
481 | return LazyHolder.INSTANCE; | ||
482 | } catch (ExceptionInInitializerError err) { | ||
483 | throw processInitializerError(err); | ||
484 | } | ||
485 | } | ||
486 | |||
487 | @Override | ||
488 | protected TooManyInputsOfSegment.Matcher instantiate(final ViatraQueryEngine engine) { | ||
489 | return TooManyInputsOfSegment.Matcher.on(engine); | ||
490 | } | ||
491 | |||
492 | @Override | ||
493 | public TooManyInputsOfSegment.Matcher instantiate() { | ||
494 | return TooManyInputsOfSegment.Matcher.create(); | ||
495 | } | ||
496 | |||
497 | @Override | ||
498 | public TooManyInputsOfSegment.Match newEmptyMatch() { | ||
499 | return TooManyInputsOfSegment.Match.newEmptyMatch(); | ||
500 | } | ||
501 | |||
502 | @Override | ||
503 | public TooManyInputsOfSegment.Match newMatch(final Object... parameters) { | ||
504 | return TooManyInputsOfSegment.Match.newMatch((modes3.Segment) parameters[0]); | ||
505 | } | ||
506 | |||
507 | /** | ||
508 | * Inner class allowing the singleton instance of {@link TooManyInputsOfSegment} to be created | ||
509 | * <b>not</b> at the class load time of the outer class, | ||
510 | * but rather at the first call to {@link TooManyInputsOfSegment#instance()}. | ||
511 | * | ||
512 | * <p> This workaround is required e.g. to support recursion. | ||
513 | * | ||
514 | */ | ||
515 | private static class LazyHolder { | ||
516 | private static final TooManyInputsOfSegment INSTANCE = new TooManyInputsOfSegment(); | ||
517 | |||
518 | /** | ||
519 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
520 | * This initialization order is required to support indirect recursion. | ||
521 | * | ||
522 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
523 | * | ||
524 | */ | ||
525 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
526 | |||
527 | public static Object ensureInitialized() { | ||
528 | INSTANCE.ensureInitializedInternal(); | ||
529 | return null; | ||
530 | } | ||
531 | } | ||
532 | |||
533 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
534 | private static final TooManyInputsOfSegment.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
535 | |||
536 | private final PParameter parameter_S = new PParameter("S", "modes3.Segment", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.ece.mcgill.ca/wcet/modes3", "Segment")), PParameterDirection.INOUT); | ||
537 | |||
538 | private final List<PParameter> parameters = Arrays.asList(parameter_S); | ||
539 | |||
540 | private GeneratedPQuery() { | ||
541 | super(PVisibility.PUBLIC); | ||
542 | } | ||
543 | |||
544 | @Override | ||
545 | public String getFullyQualifiedName() { | ||
546 | return "modes3.queries.tooManyInputsOfSegment"; | ||
547 | } | ||
548 | |||
549 | @Override | ||
550 | public List<String> getParameterNames() { | ||
551 | return Arrays.asList("S"); | ||
552 | } | ||
553 | |||
554 | @Override | ||
555 | public List<PParameter> getParameters() { | ||
556 | return parameters; | ||
557 | } | ||
558 | |||
559 | @Override | ||
560 | public Set<PBody> doGetContainedBodies() { | ||
561 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
562 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
563 | { | ||
564 | PBody body = new PBody(this); | ||
565 | PVariable var_S = body.getOrCreateVariableByName("S"); | ||
566 | PVariable var_I1 = body.getOrCreateVariableByName("I1"); | ||
567 | PVariable var_I2 = body.getOrCreateVariableByName("I2"); | ||
568 | PVariable var_I3 = body.getOrCreateVariableByName("I3"); | ||
569 | new TypeConstraint(body, Tuples.flatTupleOf(var_S), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.ece.mcgill.ca/wcet/modes3", "Segment"))); | ||
570 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
571 | new ExportedParameter(body, var_S, parameter_S) | ||
572 | )); | ||
573 | // neg find turnout(S) | ||
574 | new NegativePatternCall(body, Tuples.flatTupleOf(var_S), Turnout.instance().getInternalQueryRepresentation()); | ||
575 | // find output(I1, S) | ||
576 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I1, var_S), Output.instance().getInternalQueryRepresentation()); | ||
577 | // find output(I2, S) | ||
578 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I2, var_S), Output.instance().getInternalQueryRepresentation()); | ||
579 | // find output(I3, S) | ||
580 | new PositivePatternCall(body, Tuples.flatTupleOf(var_I3, var_S), Output.instance().getInternalQueryRepresentation()); | ||
581 | // I1 != I2 | ||
582 | new Inequality(body, var_I1, var_I2); | ||
583 | // I1 != I3 | ||
584 | new Inequality(body, var_I1, var_I3); | ||
585 | // I2 != I3 | ||
586 | new Inequality(body, var_I2, var_I3); | ||
587 | bodies.add(body); | ||
588 | } | ||
589 | { | ||
590 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
591 | annotation.addAttribute("message", "tooManyInputsOfSegment"); | ||
592 | annotation.addAttribute("severity", "error"); | ||
593 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
594 | new ParameterReference("S") | ||
595 | })); | ||
596 | addAnnotation(annotation); | ||
597 | } | ||
598 | return bodies; | ||
599 | } | ||
600 | } | ||
601 | } | ||