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