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