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