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