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