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