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