aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/github-graph/src-gen/queries/CheckUserAction.java
diff options
context:
space:
mode:
Diffstat (limited to 'Domains/github-graph/src-gen/queries/CheckUserAction.java')
-rw-r--r--Domains/github-graph/src-gen/queries/CheckUserAction.java946
1 files changed, 946 insertions, 0 deletions
diff --git a/Domains/github-graph/src-gen/queries/CheckUserAction.java b/Domains/github-graph/src-gen/queries/CheckUserAction.java
new file mode 100644
index 00000000..d26c0031
--- /dev/null
+++ b/Domains/github-graph/src-gen/queries/CheckUserAction.java
@@ -0,0 +1,946 @@
1/**
2 * Generated from platform:/resource/github-graph/queries/queries/github.vql
3 */
4package queries;
5
6import github.Action;
7import github.Issue;
8import github.IssueEvent;
9import github.User;
10import java.util.Arrays;
11import java.util.Collection;
12import java.util.LinkedHashSet;
13import java.util.List;
14import java.util.Objects;
15import java.util.Optional;
16import java.util.Set;
17import java.util.function.Consumer;
18import java.util.stream.Collectors;
19import java.util.stream.Stream;
20import org.apache.log4j.Logger;
21import org.eclipse.emf.ecore.EClass;
22import org.eclipse.emf.ecore.EDataType;
23import org.eclipse.viatra.query.runtime.api.IPatternMatch;
24import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
26import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
27import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
28import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
29import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
30import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
31import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
32import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
33import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
34import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
35import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
44import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
45
46/**
47 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
48 *
49 * <p>Original source:
50 * <code><pre>
51 * pattern checkUserAction(i: Issue, u: User, e: IssueEvent, t: Action) {
52 * Issue.issueevent(i, e);
53 * IssueEvent.user(e, u);
54 * IssueEvent.action(e, a);
55 * a == t;
56 * }
57 * </pre></code>
58 *
59 * @see Matcher
60 * @see Match
61 *
62 */
63@SuppressWarnings("all")
64public final class CheckUserAction extends BaseGeneratedEMFQuerySpecification<CheckUserAction.Matcher> {
65 /**
66 * Pattern-specific match representation of the queries.checkUserAction 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 Issue fI;
79
80 private User fU;
81
82 private IssueEvent fE;
83
84 private Action fT;
85
86 private static List<String> parameterNames = makeImmutableList("i", "u", "e", "t");
87
88 private Match(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
89 this.fI = pI;
90 this.fU = pU;
91 this.fE = pE;
92 this.fT = pT;
93 }
94
95 @Override
96 public Object get(final String parameterName) {
97 switch(parameterName) {
98 case "i": return this.fI;
99 case "u": return this.fU;
100 case "e": return this.fE;
101 case "t": return this.fT;
102 default: return null;
103 }
104 }
105
106 @Override
107 public Object get(final int index) {
108 switch(index) {
109 case 0: return this.fI;
110 case 1: return this.fU;
111 case 2: return this.fE;
112 case 3: return this.fT;
113 default: return null;
114 }
115 }
116
117 public Issue getI() {
118 return this.fI;
119 }
120
121 public User getU() {
122 return this.fU;
123 }
124
125 public IssueEvent getE() {
126 return this.fE;
127 }
128
129 public Action getT() {
130 return this.fT;
131 }
132
133 @Override
134 public boolean set(final String parameterName, final Object newValue) {
135 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
136 if ("i".equals(parameterName) ) {
137 this.fI = (Issue) newValue;
138 return true;
139 }
140 if ("u".equals(parameterName) ) {
141 this.fU = (User) newValue;
142 return true;
143 }
144 if ("e".equals(parameterName) ) {
145 this.fE = (IssueEvent) newValue;
146 return true;
147 }
148 if ("t".equals(parameterName) ) {
149 this.fT = (Action) newValue;
150 return true;
151 }
152 return false;
153 }
154
155 public void setI(final Issue pI) {
156 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
157 this.fI = pI;
158 }
159
160 public void setU(final User pU) {
161 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
162 this.fU = pU;
163 }
164
165 public void setE(final IssueEvent pE) {
166 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
167 this.fE = pE;
168 }
169
170 public void setT(final Action pT) {
171 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
172 this.fT = pT;
173 }
174
175 @Override
176 public String patternName() {
177 return "queries.checkUserAction";
178 }
179
180 @Override
181 public List<String> parameterNames() {
182 return CheckUserAction.Match.parameterNames;
183 }
184
185 @Override
186 public Object[] toArray() {
187 return new Object[]{fI, fU, fE, fT};
188 }
189
190 @Override
191 public CheckUserAction.Match toImmutable() {
192 return isMutable() ? newMatch(fI, fU, fE, fT) : this;
193 }
194
195 @Override
196 public String prettyPrint() {
197 StringBuilder result = new StringBuilder();
198 result.append("\"i\"=" + prettyPrintValue(fI) + ", ");
199 result.append("\"u\"=" + prettyPrintValue(fU) + ", ");
200 result.append("\"e\"=" + prettyPrintValue(fE) + ", ");
201 result.append("\"t\"=" + prettyPrintValue(fT));
202 return result.toString();
203 }
204
205 @Override
206 public int hashCode() {
207 return Objects.hash(fI, fU, fE, fT);
208 }
209
210 @Override
211 public boolean equals(final Object obj) {
212 if (this == obj)
213 return true;
214 if (obj == null) {
215 return false;
216 }
217 if ((obj instanceof CheckUserAction.Match)) {
218 CheckUserAction.Match other = (CheckUserAction.Match) obj;
219 return Objects.equals(fI, other.fI) && Objects.equals(fU, other.fU) && Objects.equals(fE, other.fE) && Objects.equals(fT, other.fT);
220 } else {
221 // this should be infrequent
222 if (!(obj instanceof IPatternMatch)) {
223 return false;
224 }
225 IPatternMatch otherSig = (IPatternMatch) obj;
226 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
227 }
228 }
229
230 @Override
231 public CheckUserAction specification() {
232 return CheckUserAction.instance();
233 }
234
235 /**
236 * Returns an empty, mutable match.
237 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
238 *
239 * @return the empty match.
240 *
241 */
242 public static CheckUserAction.Match newEmptyMatch() {
243 return new Mutable(null, null, null, null);
244 }
245
246 /**
247 * Returns a mutable (partial) match.
248 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
249 *
250 * @param pI the fixed value of pattern parameter i, or null if not bound.
251 * @param pU the fixed value of pattern parameter u, or null if not bound.
252 * @param pE the fixed value of pattern parameter e, or null if not bound.
253 * @param pT the fixed value of pattern parameter t, or null if not bound.
254 * @return the new, mutable (partial) match object.
255 *
256 */
257 public static CheckUserAction.Match newMutableMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
258 return new Mutable(pI, pU, pE, pT);
259 }
260
261 /**
262 * Returns a new (partial) match.
263 * This can be used e.g. to call the matcher with a partial match.
264 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
265 * @param pI the fixed value of pattern parameter i, or null if not bound.
266 * @param pU the fixed value of pattern parameter u, or null if not bound.
267 * @param pE the fixed value of pattern parameter e, or null if not bound.
268 * @param pT the fixed value of pattern parameter t, or null if not bound.
269 * @return the (partial) match object.
270 *
271 */
272 public static CheckUserAction.Match newMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
273 return new Immutable(pI, pU, pE, pT);
274 }
275
276 private static final class Mutable extends CheckUserAction.Match {
277 Mutable(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
278 super(pI, pU, pE, pT);
279 }
280
281 @Override
282 public boolean isMutable() {
283 return true;
284 }
285 }
286
287 private static final class Immutable extends CheckUserAction.Match {
288 Immutable(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
289 super(pI, pU, pE, pT);
290 }
291
292 @Override
293 public boolean isMutable() {
294 return false;
295 }
296 }
297 }
298
299 /**
300 * Generated pattern matcher API of the queries.checkUserAction pattern,
301 * providing pattern-specific query methods.
302 *
303 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
304 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
305 *
306 * <p>Matches of the pattern will be represented as {@link Match}.
307 *
308 * <p>Original source:
309 * <code><pre>
310 * pattern checkUserAction(i: Issue, u: User, e: IssueEvent, t: Action) {
311 * Issue.issueevent(i, e);
312 * IssueEvent.user(e, u);
313 * IssueEvent.action(e, a);
314 * a == t;
315 * }
316 * </pre></code>
317 *
318 * @see Match
319 * @see CheckUserAction
320 *
321 */
322 public static class Matcher extends BaseMatcher<CheckUserAction.Match> {
323 /**
324 * Initializes the pattern matcher within an existing VIATRA Query engine.
325 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
326 *
327 * @param engine the existing VIATRA Query engine in which this matcher will be created.
328 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
329 *
330 */
331 public static CheckUserAction.Matcher on(final ViatraQueryEngine engine) {
332 // check if matcher already exists
333 Matcher matcher = engine.getExistingMatcher(querySpecification());
334 if (matcher == null) {
335 matcher = (Matcher)engine.getMatcher(querySpecification());
336 }
337 return matcher;
338 }
339
340 /**
341 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
342 * @return an initialized matcher
343 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
344 *
345 */
346 public static CheckUserAction.Matcher create() {
347 return new Matcher();
348 }
349
350 private static final int POSITION_I = 0;
351
352 private static final int POSITION_U = 1;
353
354 private static final int POSITION_E = 2;
355
356 private static final int POSITION_T = 3;
357
358 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CheckUserAction.Matcher.class);
359
360 /**
361 * Initializes the pattern matcher within an existing VIATRA Query engine.
362 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
363 *
364 * @param engine the existing VIATRA Query engine in which this matcher will be created.
365 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
366 *
367 */
368 private Matcher() {
369 super(querySpecification());
370 }
371
372 /**
373 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
374 * @param pI the fixed value of pattern parameter i, or null if not bound.
375 * @param pU the fixed value of pattern parameter u, or null if not bound.
376 * @param pE the fixed value of pattern parameter e, or null if not bound.
377 * @param pT the fixed value of pattern parameter t, or null if not bound.
378 * @return matches represented as a Match object.
379 *
380 */
381 public Collection<CheckUserAction.Match> getAllMatches(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
382 return rawStreamAllMatches(new Object[]{pI, pU, pE, pT}).collect(Collectors.toSet());
383 }
384
385 /**
386 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
387 * </p>
388 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
389 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
390 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
391 * @param pI the fixed value of pattern parameter i, or null if not bound.
392 * @param pU the fixed value of pattern parameter u, or null if not bound.
393 * @param pE the fixed value of pattern parameter e, or null if not bound.
394 * @param pT the fixed value of pattern parameter t, or null if not bound.
395 * @return a stream of matches represented as a Match object.
396 *
397 */
398 public Stream<CheckUserAction.Match> streamAllMatches(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
399 return rawStreamAllMatches(new Object[]{pI, pU, pE, pT});
400 }
401
402 /**
403 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
404 * Neither determinism nor randomness of selection is guaranteed.
405 * @param pI the fixed value of pattern parameter i, or null if not bound.
406 * @param pU the fixed value of pattern parameter u, or null if not bound.
407 * @param pE the fixed value of pattern parameter e, or null if not bound.
408 * @param pT the fixed value of pattern parameter t, or null if not bound.
409 * @return a match represented as a Match object, or null if no match is found.
410 *
411 */
412 public Optional<CheckUserAction.Match> getOneArbitraryMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
413 return rawGetOneArbitraryMatch(new Object[]{pI, pU, pE, pT});
414 }
415
416 /**
417 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
418 * under any possible substitution of the unspecified parameters (if any).
419 * @param pI the fixed value of pattern parameter i, or null if not bound.
420 * @param pU the fixed value of pattern parameter u, or null if not bound.
421 * @param pE the fixed value of pattern parameter e, or null if not bound.
422 * @param pT the fixed value of pattern parameter t, or null if not bound.
423 * @return true if the input is a valid (partial) match of the pattern.
424 *
425 */
426 public boolean hasMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
427 return rawHasMatch(new Object[]{pI, pU, pE, pT});
428 }
429
430 /**
431 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
432 * @param pI the fixed value of pattern parameter i, or null if not bound.
433 * @param pU the fixed value of pattern parameter u, or null if not bound.
434 * @param pE the fixed value of pattern parameter e, or null if not bound.
435 * @param pT the fixed value of pattern parameter t, or null if not bound.
436 * @return the number of pattern matches found.
437 *
438 */
439 public int countMatches(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
440 return rawCountMatches(new Object[]{pI, pU, pE, pT});
441 }
442
443 /**
444 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
445 * Neither determinism nor randomness of selection is guaranteed.
446 * @param pI the fixed value of pattern parameter i, or null if not bound.
447 * @param pU the fixed value of pattern parameter u, or null if not bound.
448 * @param pE the fixed value of pattern parameter e, or null if not bound.
449 * @param pT the fixed value of pattern parameter t, or null if not bound.
450 * @param processor the action that will process the selected match.
451 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
452 *
453 */
454 public boolean forOneArbitraryMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT, final Consumer<? super CheckUserAction.Match> processor) {
455 return rawForOneArbitraryMatch(new Object[]{pI, pU, pE, pT}, processor);
456 }
457
458 /**
459 * Returns a new (partial) match.
460 * This can be used e.g. to call the matcher with a partial match.
461 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
462 * @param pI the fixed value of pattern parameter i, or null if not bound.
463 * @param pU the fixed value of pattern parameter u, or null if not bound.
464 * @param pE the fixed value of pattern parameter e, or null if not bound.
465 * @param pT the fixed value of pattern parameter t, or null if not bound.
466 * @return the (partial) match object.
467 *
468 */
469 public CheckUserAction.Match newMatch(final Issue pI, final User pU, final IssueEvent pE, final Action pT) {
470 return CheckUserAction.Match.newMatch(pI, pU, pE, pT);
471 }
472
473 /**
474 * Retrieve the set of values that occur in matches for i.
475 * @return the Set of all values or empty set if there are no matches
476 *
477 */
478 protected Stream<Issue> rawStreamAllValuesOfi(final Object[] parameters) {
479 return rawStreamAllValues(POSITION_I, parameters).map(Issue.class::cast);
480 }
481
482 /**
483 * Retrieve the set of values that occur in matches for i.
484 * @return the Set of all values or empty set if there are no matches
485 *
486 */
487 public Set<Issue> getAllValuesOfi() {
488 return rawStreamAllValuesOfi(emptyArray()).collect(Collectors.toSet());
489 }
490
491 /**
492 * Retrieve the set of values that occur in matches for i.
493 * @return the Set of all values or empty set if there are no matches
494 *
495 */
496 public Stream<Issue> streamAllValuesOfi() {
497 return rawStreamAllValuesOfi(emptyArray());
498 }
499
500 /**
501 * Retrieve the set of values that occur in matches for i.
502 * </p>
503 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
504 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
505 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
506 *
507 * @return the Stream of all values or empty set if there are no matches
508 *
509 */
510 public Stream<Issue> streamAllValuesOfi(final CheckUserAction.Match partialMatch) {
511 return rawStreamAllValuesOfi(partialMatch.toArray());
512 }
513
514 /**
515 * Retrieve the set of values that occur in matches for i.
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<Issue> streamAllValuesOfi(final User pU, final IssueEvent pE, final Action pT) {
525 return rawStreamAllValuesOfi(new Object[]{null, pU, pE, pT});
526 }
527
528 /**
529 * Retrieve the set of values that occur in matches for i.
530 * @return the Set of all values or empty set if there are no matches
531 *
532 */
533 public Set<Issue> getAllValuesOfi(final CheckUserAction.Match partialMatch) {
534 return rawStreamAllValuesOfi(partialMatch.toArray()).collect(Collectors.toSet());
535 }
536
537 /**
538 * Retrieve the set of values that occur in matches for i.
539 * @return the Set of all values or empty set if there are no matches
540 *
541 */
542 public Set<Issue> getAllValuesOfi(final User pU, final IssueEvent pE, final Action pT) {
543 return rawStreamAllValuesOfi(new Object[]{null, pU, pE, pT}).collect(Collectors.toSet());
544 }
545
546 /**
547 * Retrieve the set of values that occur in matches for u.
548 * @return the Set of all values or empty set if there are no matches
549 *
550 */
551 protected Stream<User> rawStreamAllValuesOfu(final Object[] parameters) {
552 return rawStreamAllValues(POSITION_U, parameters).map(User.class::cast);
553 }
554
555 /**
556 * Retrieve the set of values that occur in matches for u.
557 * @return the Set of all values or empty set if there are no matches
558 *
559 */
560 public Set<User> getAllValuesOfu() {
561 return rawStreamAllValuesOfu(emptyArray()).collect(Collectors.toSet());
562 }
563
564 /**
565 * Retrieve the set of values that occur in matches for u.
566 * @return the Set of all values or empty set if there are no matches
567 *
568 */
569 public Stream<User> streamAllValuesOfu() {
570 return rawStreamAllValuesOfu(emptyArray());
571 }
572
573 /**
574 * Retrieve the set of values that occur in matches for u.
575 * </p>
576 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
577 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
578 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
579 *
580 * @return the Stream of all values or empty set if there are no matches
581 *
582 */
583 public Stream<User> streamAllValuesOfu(final CheckUserAction.Match partialMatch) {
584 return rawStreamAllValuesOfu(partialMatch.toArray());
585 }
586
587 /**
588 * Retrieve the set of values that occur in matches for u.
589 * </p>
590 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
591 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
592 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
593 *
594 * @return the Stream of all values or empty set if there are no matches
595 *
596 */
597 public Stream<User> streamAllValuesOfu(final Issue pI, final IssueEvent pE, final Action pT) {
598 return rawStreamAllValuesOfu(new Object[]{pI, null, pE, pT});
599 }
600
601 /**
602 * Retrieve the set of values that occur in matches for u.
603 * @return the Set of all values or empty set if there are no matches
604 *
605 */
606 public Set<User> getAllValuesOfu(final CheckUserAction.Match partialMatch) {
607 return rawStreamAllValuesOfu(partialMatch.toArray()).collect(Collectors.toSet());
608 }
609
610 /**
611 * Retrieve the set of values that occur in matches for u.
612 * @return the Set of all values or empty set if there are no matches
613 *
614 */
615 public Set<User> getAllValuesOfu(final Issue pI, final IssueEvent pE, final Action pT) {
616 return rawStreamAllValuesOfu(new Object[]{pI, null, pE, pT}).collect(Collectors.toSet());
617 }
618
619 /**
620 * Retrieve the set of values that occur in matches for e.
621 * @return the Set of all values or empty set if there are no matches
622 *
623 */
624 protected Stream<IssueEvent> rawStreamAllValuesOfe(final Object[] parameters) {
625 return rawStreamAllValues(POSITION_E, parameters).map(IssueEvent.class::cast);
626 }
627
628 /**
629 * Retrieve the set of values that occur in matches for e.
630 * @return the Set of all values or empty set if there are no matches
631 *
632 */
633 public Set<IssueEvent> getAllValuesOfe() {
634 return rawStreamAllValuesOfe(emptyArray()).collect(Collectors.toSet());
635 }
636
637 /**
638 * Retrieve the set of values that occur in matches for e.
639 * @return the Set of all values or empty set if there are no matches
640 *
641 */
642 public Stream<IssueEvent> streamAllValuesOfe() {
643 return rawStreamAllValuesOfe(emptyArray());
644 }
645
646 /**
647 * Retrieve the set of values that occur in matches for e.
648 * </p>
649 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
650 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
651 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
652 *
653 * @return the Stream of all values or empty set if there are no matches
654 *
655 */
656 public Stream<IssueEvent> streamAllValuesOfe(final CheckUserAction.Match partialMatch) {
657 return rawStreamAllValuesOfe(partialMatch.toArray());
658 }
659
660 /**
661 * Retrieve the set of values that occur in matches for e.
662 * </p>
663 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
664 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
665 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
666 *
667 * @return the Stream of all values or empty set if there are no matches
668 *
669 */
670 public Stream<IssueEvent> streamAllValuesOfe(final Issue pI, final User pU, final Action pT) {
671 return rawStreamAllValuesOfe(new Object[]{pI, pU, null, pT});
672 }
673
674 /**
675 * Retrieve the set of values that occur in matches for e.
676 * @return the Set of all values or empty set if there are no matches
677 *
678 */
679 public Set<IssueEvent> getAllValuesOfe(final CheckUserAction.Match partialMatch) {
680 return rawStreamAllValuesOfe(partialMatch.toArray()).collect(Collectors.toSet());
681 }
682
683 /**
684 * Retrieve the set of values that occur in matches for e.
685 * @return the Set of all values or empty set if there are no matches
686 *
687 */
688 public Set<IssueEvent> getAllValuesOfe(final Issue pI, final User pU, final Action pT) {
689 return rawStreamAllValuesOfe(new Object[]{pI, pU, null, pT}).collect(Collectors.toSet());
690 }
691
692 /**
693 * Retrieve the set of values that occur in matches for t.
694 * @return the Set of all values or empty set if there are no matches
695 *
696 */
697 protected Stream<Action> rawStreamAllValuesOft(final Object[] parameters) {
698 return rawStreamAllValues(POSITION_T, parameters).map(Action.class::cast);
699 }
700
701 /**
702 * Retrieve the set of values that occur in matches for t.
703 * @return the Set of all values or empty set if there are no matches
704 *
705 */
706 public Set<Action> getAllValuesOft() {
707 return rawStreamAllValuesOft(emptyArray()).collect(Collectors.toSet());
708 }
709
710 /**
711 * Retrieve the set of values that occur in matches for t.
712 * @return the Set of all values or empty set if there are no matches
713 *
714 */
715 public Stream<Action> streamAllValuesOft() {
716 return rawStreamAllValuesOft(emptyArray());
717 }
718
719 /**
720 * Retrieve the set of values that occur in matches for t.
721 * </p>
722 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
723 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
724 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
725 *
726 * @return the Stream of all values or empty set if there are no matches
727 *
728 */
729 public Stream<Action> streamAllValuesOft(final CheckUserAction.Match partialMatch) {
730 return rawStreamAllValuesOft(partialMatch.toArray());
731 }
732
733 /**
734 * Retrieve the set of values that occur in matches for t.
735 * </p>
736 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
737 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
738 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
739 *
740 * @return the Stream of all values or empty set if there are no matches
741 *
742 */
743 public Stream<Action> streamAllValuesOft(final Issue pI, final User pU, final IssueEvent pE) {
744 return rawStreamAllValuesOft(new Object[]{pI, pU, pE, null});
745 }
746
747 /**
748 * Retrieve the set of values that occur in matches for t.
749 * @return the Set of all values or empty set if there are no matches
750 *
751 */
752 public Set<Action> getAllValuesOft(final CheckUserAction.Match partialMatch) {
753 return rawStreamAllValuesOft(partialMatch.toArray()).collect(Collectors.toSet());
754 }
755
756 /**
757 * Retrieve the set of values that occur in matches for t.
758 * @return the Set of all values or empty set if there are no matches
759 *
760 */
761 public Set<Action> getAllValuesOft(final Issue pI, final User pU, final IssueEvent pE) {
762 return rawStreamAllValuesOft(new Object[]{pI, pU, pE, null}).collect(Collectors.toSet());
763 }
764
765 @Override
766 protected CheckUserAction.Match tupleToMatch(final Tuple t) {
767 try {
768 return CheckUserAction.Match.newMatch((Issue) t.get(POSITION_I), (User) t.get(POSITION_U), (IssueEvent) t.get(POSITION_E), (Action) t.get(POSITION_T));
769 } catch(ClassCastException e) {
770 LOGGER.error("Element(s) in tuple not properly typed!",e);
771 return null;
772 }
773 }
774
775 @Override
776 protected CheckUserAction.Match arrayToMatch(final Object[] match) {
777 try {
778 return CheckUserAction.Match.newMatch((Issue) match[POSITION_I], (User) match[POSITION_U], (IssueEvent) match[POSITION_E], (Action) match[POSITION_T]);
779 } catch(ClassCastException e) {
780 LOGGER.error("Element(s) in array not properly typed!",e);
781 return null;
782 }
783 }
784
785 @Override
786 protected CheckUserAction.Match arrayToMatchMutable(final Object[] match) {
787 try {
788 return CheckUserAction.Match.newMutableMatch((Issue) match[POSITION_I], (User) match[POSITION_U], (IssueEvent) match[POSITION_E], (Action) match[POSITION_T]);
789 } catch(ClassCastException e) {
790 LOGGER.error("Element(s) in array not properly typed!",e);
791 return null;
792 }
793 }
794
795 /**
796 * @return the singleton instance of the query specification of this pattern
797 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
798 *
799 */
800 public static IQuerySpecification<CheckUserAction.Matcher> querySpecification() {
801 return CheckUserAction.instance();
802 }
803 }
804
805 private CheckUserAction() {
806 super(GeneratedPQuery.INSTANCE);
807 }
808
809 /**
810 * @return the singleton instance of the query specification
811 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
812 *
813 */
814 public static CheckUserAction instance() {
815 try{
816 return LazyHolder.INSTANCE;
817 } catch (ExceptionInInitializerError err) {
818 throw processInitializerError(err);
819 }
820 }
821
822 @Override
823 protected CheckUserAction.Matcher instantiate(final ViatraQueryEngine engine) {
824 return CheckUserAction.Matcher.on(engine);
825 }
826
827 @Override
828 public CheckUserAction.Matcher instantiate() {
829 return CheckUserAction.Matcher.create();
830 }
831
832 @Override
833 public CheckUserAction.Match newEmptyMatch() {
834 return CheckUserAction.Match.newEmptyMatch();
835 }
836
837 @Override
838 public CheckUserAction.Match newMatch(final Object... parameters) {
839 return CheckUserAction.Match.newMatch((github.Issue) parameters[0], (github.User) parameters[1], (github.IssueEvent) parameters[2], (github.Action) parameters[3]);
840 }
841
842 /**
843 * Inner class allowing the singleton instance of {@link CheckUserAction} to be created
844 * <b>not</b> at the class load time of the outer class,
845 * but rather at the first call to {@link CheckUserAction#instance()}.
846 *
847 * <p> This workaround is required e.g. to support recursion.
848 *
849 */
850 private static class LazyHolder {
851 private static final CheckUserAction INSTANCE = new CheckUserAction();
852
853 /**
854 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
855 * This initialization order is required to support indirect recursion.
856 *
857 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
858 *
859 */
860 private static final Object STATIC_INITIALIZER = ensureInitialized();
861
862 public static Object ensureInitialized() {
863 INSTANCE.ensureInitializedInternal();
864 return null;
865 }
866 }
867
868 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
869 private static final CheckUserAction.GeneratedPQuery INSTANCE = new GeneratedPQuery();
870
871 private final PParameter parameter_i = new PParameter("i", "github.Issue", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "Issue")), PParameterDirection.INOUT);
872
873 private final PParameter parameter_u = new PParameter("u", "github.User", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "User")), PParameterDirection.INOUT);
874
875 private final PParameter parameter_e = new PParameter("e", "github.IssueEvent", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("sure.ghtorrent.github", "IssueEvent")), PParameterDirection.INOUT);
876
877 private final PParameter parameter_t = new PParameter("t", "github.Action", new EDataTypeInSlotsKey((EDataType)getClassifierLiteralSafe("sure.ghtorrent.github", "Action")), PParameterDirection.INOUT);
878
879 private final List<PParameter> parameters = Arrays.asList(parameter_i, parameter_u, parameter_e, parameter_t);
880
881 private GeneratedPQuery() {
882 super(PVisibility.PUBLIC);
883 }
884
885 @Override
886 public String getFullyQualifiedName() {
887 return "queries.checkUserAction";
888 }
889
890 @Override
891 public List<String> getParameterNames() {
892 return Arrays.asList("i","u","e","t");
893 }
894
895 @Override
896 public List<PParameter> getParameters() {
897 return parameters;
898 }
899
900 @Override
901 public Set<PBody> doGetContainedBodies() {
902 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
903 Set<PBody> bodies = new LinkedHashSet<>();
904 {
905 PBody body = new PBody(this);
906 PVariable var_i = body.getOrCreateVariableByName("i");
907 PVariable var_u = body.getOrCreateVariableByName("u");
908 PVariable var_e = body.getOrCreateVariableByName("e");
909 PVariable var_t = body.getOrCreateVariableByName("t");
910 PVariable var_a = body.getOrCreateVariableByName("a");
911 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
912 new TypeConstraint(body, Tuples.flatTupleOf(var_u), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
913 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
914 new TypeConstraint(body, Tuples.flatTupleOf(var_t), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("sure.ghtorrent.github", "Action")));
915 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
916 new ExportedParameter(body, var_i, parameter_i),
917 new ExportedParameter(body, var_u, parameter_u),
918 new ExportedParameter(body, var_e, parameter_e),
919 new ExportedParameter(body, var_t, parameter_t)
920 ));
921 // Issue.issueevent(i, e)
922 new TypeConstraint(body, Tuples.flatTupleOf(var_i), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "Issue")));
923 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
924 new TypeConstraint(body, Tuples.flatTupleOf(var_i, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "Issue", "issueevent")));
925 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
926 new Equality(body, var__virtual_0_, var_e);
927 // IssueEvent.user(e, u)
928 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
929 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
930 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "user")));
931 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "User")));
932 new Equality(body, var__virtual_1_, var_u);
933 // IssueEvent.action(e, a)
934 new TypeConstraint(body, Tuples.flatTupleOf(var_e), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("sure.ghtorrent.github", "IssueEvent")));
935 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
936 new TypeConstraint(body, Tuples.flatTupleOf(var_e, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("sure.ghtorrent.github", "IssueEvent", "action")));
937 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("sure.ghtorrent.github", "Action")));
938 new Equality(body, var__virtual_2_, var_a);
939 // a == t
940 new Equality(body, var_a, var_t);
941 bodies.add(body);
942 }
943 return bodies;
944 }
945 }
946}