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