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