aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv13.java
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv13.java')
-rw-r--r--Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv13.java591
1 files changed, 0 insertions, 591 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv13.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv13.java
deleted file mode 100644
index a4aea47c..00000000
--- a/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv13.java
+++ /dev/null
@@ -1,591 +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.emf.ecore.EDataType;
20import org.eclipse.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey;
29import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey;
30import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
32import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
33import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
34import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.ConstantValue;
39import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
42import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
44import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
45import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
46import queries.X_inv13;
47
48/**
49 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
50 *
51 * <p>Original source:
52 * <code><pre>
53 * //inv13 - Added new containment rel Phys_Pers-{@literal >}Address
54 * //exists - handled logically
55 * {@literal @}Constraint(message = "inv13", severity = "error", key = {tp})
56 * pattern inv13(tp : Tax_Payer) {
57 * Tax_Payer.addresses(tp, hab_add);
58 * Habitual_Address(hab_add);
59 * Address.country(hab_add, ::ZZ);
60 * neg find x_inv13(tp);
61 * }
62 * </pre></code>
63 *
64 * @see Matcher
65 * @see Match
66 *
67 */
68@SuppressWarnings("all")
69public final class Inv13 extends BaseGeneratedEMFQuerySpecification<Inv13.Matcher> {
70 /**
71 * Pattern-specific match representation of the queries.inv13 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.inv13";
129 }
130
131 @Override
132 public List<String> parameterNames() {
133 return Inv13.Match.parameterNames;
134 }
135
136 @Override
137 public Object[] toArray() {
138 return new Object[]{fTp};
139 }
140
141 @Override
142 public Inv13.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 Inv13.Match)) {
166 Inv13.Match other = (Inv13.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 Inv13 specification() {
180 return Inv13.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 Inv13.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 Inv13.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 Inv13.Match newMatch(final Tax_Payer pTp) {
215 return new Immutable(pTp);
216 }
217
218 private static final class Mutable extends Inv13.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 Inv13.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.inv13 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 * //inv13 - Added new containment rel Phys_Pers-{@literal >}Address
253 * //exists - handled logically
254 * {@literal @}Constraint(message = "inv13", severity = "error", key = {tp})
255 * pattern inv13(tp : Tax_Payer) {
256 * Tax_Payer.addresses(tp, hab_add);
257 * Habitual_Address(hab_add);
258 * Address.country(hab_add, ::ZZ);
259 * neg find x_inv13(tp);
260 * }
261 * </pre></code>
262 *
263 * @see Match
264 * @see Inv13
265 *
266 */
267 public static class Matcher extends BaseMatcher<Inv13.Match> {
268 /**
269 * Initializes the pattern matcher within an existing VIATRA Query engine.
270 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
271 *
272 * @param engine the existing VIATRA Query engine in which this matcher will be created.
273 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
274 *
275 */
276 public static Inv13.Matcher on(final ViatraQueryEngine engine) {
277 // check if matcher already exists
278 Matcher matcher = engine.getExistingMatcher(querySpecification());
279 if (matcher == null) {
280 matcher = (Matcher)engine.getMatcher(querySpecification());
281 }
282 return matcher;
283 }
284
285 /**
286 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
287 * @return an initialized matcher
288 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
289 *
290 */
291 public static Inv13.Matcher create() {
292 return new Matcher();
293 }
294
295 private static final int POSITION_TP = 0;
296
297 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Inv13.Matcher.class);
298
299 /**
300 * Initializes the pattern matcher within an existing VIATRA Query engine.
301 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
302 *
303 * @param engine the existing VIATRA Query engine in which this matcher will be created.
304 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
305 *
306 */
307 private Matcher() {
308 super(querySpecification());
309 }
310
311 /**
312 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
313 * @param pTp the fixed value of pattern parameter tp, or null if not bound.
314 * @return matches represented as a Match object.
315 *
316 */
317 public Collection<Inv13.Match> getAllMatches(final Tax_Payer pTp) {
318 return rawStreamAllMatches(new Object[]{pTp}).collect(Collectors.toSet());
319 }
320
321 /**
322 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
323 * </p>
324 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
325 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
326 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
327 * @param pTp the fixed value of pattern parameter tp, or null if not bound.
328 * @return a stream of matches represented as a Match object.
329 *
330 */
331 public Stream<Inv13.Match> streamAllMatches(final Tax_Payer pTp) {
332 return rawStreamAllMatches(new Object[]{pTp});
333 }
334
335 /**
336 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
337 * Neither determinism nor randomness of selection is guaranteed.
338 * @param pTp the fixed value of pattern parameter tp, or null if not bound.
339 * @return a match represented as a Match object, or null if no match is found.
340 *
341 */
342 public Optional<Inv13.Match> getOneArbitraryMatch(final Tax_Payer pTp) {
343 return rawGetOneArbitraryMatch(new Object[]{pTp});
344 }
345
346 /**
347 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
348 * under any possible substitution of the unspecified parameters (if any).
349 * @param pTp the fixed value of pattern parameter tp, or null if not bound.
350 * @return true if the input is a valid (partial) match of the pattern.
351 *
352 */
353 public boolean hasMatch(final Tax_Payer pTp) {
354 return rawHasMatch(new Object[]{pTp});
355 }
356
357 /**
358 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
359 * @param pTp the fixed value of pattern parameter tp, or null if not bound.
360 * @return the number of pattern matches found.
361 *
362 */
363 public int countMatches(final Tax_Payer pTp) {
364 return rawCountMatches(new Object[]{pTp});
365 }
366
367 /**
368 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
369 * Neither determinism nor randomness of selection is guaranteed.
370 * @param pTp the fixed value of pattern parameter tp, or null if not bound.
371 * @param processor the action that will process the selected match.
372 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
373 *
374 */
375 public boolean forOneArbitraryMatch(final Tax_Payer pTp, final Consumer<? super Inv13.Match> processor) {
376 return rawForOneArbitraryMatch(new Object[]{pTp}, processor);
377 }
378
379 /**
380 * Returns a new (partial) match.
381 * This can be used e.g. to call the matcher with a partial match.
382 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
383 * @param pTp the fixed value of pattern parameter tp, or null if not bound.
384 * @return the (partial) match object.
385 *
386 */
387 public Inv13.Match newMatch(final Tax_Payer pTp) {
388 return Inv13.Match.newMatch(pTp);
389 }
390
391 /**
392 * Retrieve the set of values that occur in matches for tp.
393 * @return the Set of all values or empty set if there are no matches
394 *
395 */
396 protected Stream<Tax_Payer> rawStreamAllValuesOftp(final Object[] parameters) {
397 return rawStreamAllValues(POSITION_TP, parameters).map(Tax_Payer.class::cast);
398 }
399
400 /**
401 * Retrieve the set of values that occur in matches for tp.
402 * @return the Set of all values or empty set if there are no matches
403 *
404 */
405 public Set<Tax_Payer> getAllValuesOftp() {
406 return rawStreamAllValuesOftp(emptyArray()).collect(Collectors.toSet());
407 }
408
409 /**
410 * Retrieve the set of values that occur in matches for tp.
411 * @return the Set of all values or empty set if there are no matches
412 *
413 */
414 public Stream<Tax_Payer> streamAllValuesOftp() {
415 return rawStreamAllValuesOftp(emptyArray());
416 }
417
418 @Override
419 protected Inv13.Match tupleToMatch(final Tuple t) {
420 try {
421 return Inv13.Match.newMatch((Tax_Payer) t.get(POSITION_TP));
422 } catch(ClassCastException e) {
423 LOGGER.error("Element(s) in tuple not properly typed!",e);
424 return null;
425 }
426 }
427
428 @Override
429 protected Inv13.Match arrayToMatch(final Object[] match) {
430 try {
431 return Inv13.Match.newMatch((Tax_Payer) match[POSITION_TP]);
432 } catch(ClassCastException e) {
433 LOGGER.error("Element(s) in array not properly typed!",e);
434 return null;
435 }
436 }
437
438 @Override
439 protected Inv13.Match arrayToMatchMutable(final Object[] match) {
440 try {
441 return Inv13.Match.newMutableMatch((Tax_Payer) match[POSITION_TP]);
442 } catch(ClassCastException e) {
443 LOGGER.error("Element(s) in array not properly typed!",e);
444 return null;
445 }
446 }
447
448 /**
449 * @return the singleton instance of the query specification of this pattern
450 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
451 *
452 */
453 public static IQuerySpecification<Inv13.Matcher> querySpecification() {
454 return Inv13.instance();
455 }
456 }
457
458 private Inv13() {
459 super(GeneratedPQuery.INSTANCE);
460 }
461
462 /**
463 * @return the singleton instance of the query specification
464 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
465 *
466 */
467 public static Inv13 instance() {
468 try{
469 return LazyHolder.INSTANCE;
470 } catch (ExceptionInInitializerError err) {
471 throw processInitializerError(err);
472 }
473 }
474
475 @Override
476 protected Inv13.Matcher instantiate(final ViatraQueryEngine engine) {
477 return Inv13.Matcher.on(engine);
478 }
479
480 @Override
481 public Inv13.Matcher instantiate() {
482 return Inv13.Matcher.create();
483 }
484
485 @Override
486 public Inv13.Match newEmptyMatch() {
487 return Inv13.Match.newEmptyMatch();
488 }
489
490 @Override
491 public Inv13.Match newMatch(final Object... parameters) {
492 return Inv13.Match.newMatch((Taxation.Tax_Payer) parameters[0]);
493 }
494
495 /**
496 * Inner class allowing the singleton instance of {@link Inv13} to be created
497 * <b>not</b> at the class load time of the outer class,
498 * but rather at the first call to {@link Inv13#instance()}.
499 *
500 * <p> This workaround is required e.g. to support recursion.
501 *
502 */
503 private static class LazyHolder {
504 private static final Inv13 INSTANCE = new Inv13();
505
506 /**
507 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
508 * This initialization order is required to support indirect recursion.
509 *
510 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
511 *
512 */
513 private static final Object STATIC_INITIALIZER = ensureInitialized();
514
515 public static Object ensureInitialized() {
516 INSTANCE.ensureInitializedInternal();
517 return null;
518 }
519 }
520
521 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
522 private static final Inv13.GeneratedPQuery INSTANCE = new GeneratedPQuery();
523
524 private final PParameter parameter_tp = new PParameter("tp", "Taxation.Tax_Payer", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http:///TaxCard.ecore", "Tax_Payer")), PParameterDirection.INOUT);
525
526 private final List<PParameter> parameters = Arrays.asList(parameter_tp);
527
528 private GeneratedPQuery() {
529 super(PVisibility.PUBLIC);
530 }
531
532 @Override
533 public String getFullyQualifiedName() {
534 return "queries.inv13";
535 }
536
537 @Override
538 public List<String> getParameterNames() {
539 return Arrays.asList("tp");
540 }
541
542 @Override
543 public List<PParameter> getParameters() {
544 return parameters;
545 }
546
547 @Override
548 public Set<PBody> doGetContainedBodies() {
549 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
550 Set<PBody> bodies = new LinkedHashSet<>();
551 {
552 PBody body = new PBody(this);
553 PVariable var_tp = body.getOrCreateVariableByName("tp");
554 PVariable var_hab_add = body.getOrCreateVariableByName("hab_add");
555 new TypeConstraint(body, Tuples.flatTupleOf(var_tp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Tax_Payer")));
556 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
557 new ExportedParameter(body, var_tp, parameter_tp)
558 ));
559 // Tax_Payer.addresses(tp, hab_add)
560 new TypeConstraint(body, Tuples.flatTupleOf(var_tp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Tax_Payer")));
561 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
562 new TypeConstraint(body, Tuples.flatTupleOf(var_tp, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Physical_Person", "addresses")));
563 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Address")));
564 new Equality(body, var__virtual_0_, var_hab_add);
565 // Habitual_Address(hab_add)
566 new TypeConstraint(body, Tuples.flatTupleOf(var_hab_add), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Habitual_Address")));
567 // Address.country(hab_add, ::ZZ)
568 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
569 new ConstantValue(body, var__virtual_1_, getEnumLiteral("http:///TaxCard.ecore", "Country", "ZZ").getInstance());
570 new TypeConstraint(body, Tuples.flatTupleOf(var_hab_add), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Address")));
571 PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}");
572 new TypeConstraint(body, Tuples.flatTupleOf(var_hab_add, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Address", "country")));
573 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http:///TaxCard.ecore", "Country")));
574 new Equality(body, var__virtual_2_, var__virtual_1_);
575 // neg find x_inv13(tp)
576 new NegativePatternCall(body, Tuples.flatTupleOf(var_tp), X_inv13.instance().getInternalQueryRepresentation());
577 bodies.add(body);
578 }
579 {
580 PAnnotation annotation = new PAnnotation("Constraint");
581 annotation.addAttribute("message", "inv13");
582 annotation.addAttribute("severity", "error");
583 annotation.addAttribute("key", Arrays.asList(new Object[] {
584 new ParameterReference("tp")
585 }));
586 addAnnotation(annotation);
587 }
588 return bodies;
589 }
590 }
591}