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