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