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