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