aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java
diff options
context:
space:
mode:
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java')
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java705
1 files changed, 705 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java
new file mode 100644
index 00000000..2c20b38e
--- /dev/null
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsApplications.java
@@ -0,0 +1,705 @@
1/**
2 * Generated from platform:/resource/hu.bme.mit.inf.dslreasoner.domains.cps/src/hu/bme/mit/inf/dslreasoner/domains/cps/queries/CpsQueries.vql
3 */
4package hu.bme.mit.inf.dslreasoner.domains.cps.queries;
5
6import hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance;
7import hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem;
8import java.util.Arrays;
9import java.util.Collection;
10import java.util.LinkedHashSet;
11import java.util.List;
12import java.util.Objects;
13import java.util.Optional;
14import java.util.Set;
15import java.util.function.Consumer;
16import java.util.stream.Collectors;
17import java.util.stream.Stream;
18import org.apache.log4j.Logger;
19import org.eclipse.emf.ecore.EClass;
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.EStructuralFeatureInstancesKey;
29import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
30import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
32import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
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 * {@literal @}QueryBasedFeature(feature = "applications")
49 * pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) {
50 * CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance);
51 * }
52 * </pre></code>
53 *
54 * @see Matcher
55 * @see Match
56 *
57 */
58@SuppressWarnings("all")
59public final class CpsApplications extends BaseGeneratedEMFQuerySpecification<CpsApplications.Matcher> {
60 /**
61 * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications pattern,
62 * to be used in conjunction with {@link Matcher}.
63 *
64 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
65 * Each instance is a (possibly partial) substitution of pattern parameters,
66 * usable to represent a match of the pattern in the result of a query,
67 * or to specify the bound (fixed) input parameters when issuing a query.
68 *
69 * @see Matcher
70 *
71 */
72 public static abstract class Match extends BasePatternMatch {
73 private CyberPhysicalSystem fCps;
74
75 private ApplicationInstance fAppInstance;
76
77 private static List<String> parameterNames = makeImmutableList("Cps", "AppInstance");
78
79 private Match(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
80 this.fCps = pCps;
81 this.fAppInstance = pAppInstance;
82 }
83
84 @Override
85 public Object get(final String parameterName) {
86 if ("Cps".equals(parameterName)) return this.fCps;
87 if ("AppInstance".equals(parameterName)) return this.fAppInstance;
88 return null;
89 }
90
91 public CyberPhysicalSystem getCps() {
92 return this.fCps;
93 }
94
95 public ApplicationInstance getAppInstance() {
96 return this.fAppInstance;
97 }
98
99 @Override
100 public boolean set(final String parameterName, final Object newValue) {
101 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
102 if ("Cps".equals(parameterName) ) {
103 this.fCps = (CyberPhysicalSystem) newValue;
104 return true;
105 }
106 if ("AppInstance".equals(parameterName) ) {
107 this.fAppInstance = (ApplicationInstance) newValue;
108 return true;
109 }
110 return false;
111 }
112
113 public void setCps(final CyberPhysicalSystem pCps) {
114 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
115 this.fCps = pCps;
116 }
117
118 public void setAppInstance(final ApplicationInstance pAppInstance) {
119 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
120 this.fAppInstance = pAppInstance;
121 }
122
123 @Override
124 public String patternName() {
125 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications";
126 }
127
128 @Override
129 public List<String> parameterNames() {
130 return CpsApplications.Match.parameterNames;
131 }
132
133 @Override
134 public Object[] toArray() {
135 return new Object[]{fCps, fAppInstance};
136 }
137
138 @Override
139 public CpsApplications.Match toImmutable() {
140 return isMutable() ? newMatch(fCps, fAppInstance) : this;
141 }
142
143 @Override
144 public String prettyPrint() {
145 StringBuilder result = new StringBuilder();
146 result.append("\"Cps\"=" + prettyPrintValue(fCps) + ", ");
147 result.append("\"AppInstance\"=" + prettyPrintValue(fAppInstance));
148 return result.toString();
149 }
150
151 @Override
152 public int hashCode() {
153 return Objects.hash(fCps, fAppInstance);
154 }
155
156 @Override
157 public boolean equals(final Object obj) {
158 if (this == obj)
159 return true;
160 if (obj == null) {
161 return false;
162 }
163 if ((obj instanceof CpsApplications.Match)) {
164 CpsApplications.Match other = (CpsApplications.Match) obj;
165 return Objects.equals(fCps, other.fCps) && Objects.equals(fAppInstance, other.fAppInstance);
166 } else {
167 // this should be infrequent
168 if (!(obj instanceof IPatternMatch)) {
169 return false;
170 }
171 IPatternMatch otherSig = (IPatternMatch) obj;
172 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
173 }
174 }
175
176 @Override
177 public CpsApplications specification() {
178 return CpsApplications.instance();
179 }
180
181 /**
182 * Returns an empty, mutable match.
183 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
184 *
185 * @return the empty match.
186 *
187 */
188 public static CpsApplications.Match newEmptyMatch() {
189 return new Mutable(null, null);
190 }
191
192 /**
193 * Returns a mutable (partial) match.
194 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
195 *
196 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
197 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
198 * @return the new, mutable (partial) match object.
199 *
200 */
201 public static CpsApplications.Match newMutableMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
202 return new Mutable(pCps, pAppInstance);
203 }
204
205 /**
206 * Returns a new (partial) match.
207 * This can be used e.g. to call the matcher with a partial match.
208 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
209 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
210 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
211 * @return the (partial) match object.
212 *
213 */
214 public static CpsApplications.Match newMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
215 return new Immutable(pCps, pAppInstance);
216 }
217
218 private static final class Mutable extends CpsApplications.Match {
219 Mutable(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
220 super(pCps, pAppInstance);
221 }
222
223 @Override
224 public boolean isMutable() {
225 return true;
226 }
227 }
228
229 private static final class Immutable extends CpsApplications.Match {
230 Immutable(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
231 super(pCps, pAppInstance);
232 }
233
234 @Override
235 public boolean isMutable() {
236 return false;
237 }
238 }
239 }
240
241 /**
242 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications 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 * {@literal @}QueryBasedFeature(feature = "applications")
253 * pattern cpsApplications(Cps : CyberPhysicalSystem, AppInstance : ApplicationInstance) {
254 * CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance);
255 * }
256 * </pre></code>
257 *
258 * @see Match
259 * @see CpsApplications
260 *
261 */
262 public static class Matcher extends BaseMatcher<CpsApplications.Match> {
263 /**
264 * Initializes the pattern matcher within an existing VIATRA Query engine.
265 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
266 *
267 * @param engine the existing VIATRA Query engine in which this matcher will be created.
268 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
269 *
270 */
271 public static CpsApplications.Matcher on(final ViatraQueryEngine engine) {
272 // check if matcher already exists
273 Matcher matcher = engine.getExistingMatcher(querySpecification());
274 if (matcher == null) {
275 matcher = (Matcher)engine.getMatcher(querySpecification());
276 }
277 return matcher;
278 }
279
280 /**
281 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
282 * @return an initialized matcher
283 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
284 *
285 */
286 public static CpsApplications.Matcher create() {
287 return new Matcher();
288 }
289
290 private static final int POSITION_CPS = 0;
291
292 private static final int POSITION_APPINSTANCE = 1;
293
294 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(CpsApplications.Matcher.class);
295
296 /**
297 * Initializes the pattern matcher within an existing VIATRA Query engine.
298 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
299 *
300 * @param engine the existing VIATRA Query engine in which this matcher will be created.
301 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
302 *
303 */
304 private Matcher() {
305 super(querySpecification());
306 }
307
308 /**
309 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
310 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
311 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
312 * @return matches represented as a Match object.
313 *
314 */
315 public Collection<CpsApplications.Match> getAllMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
316 return rawStreamAllMatches(new Object[]{pCps, pAppInstance}).collect(Collectors.toSet());
317 }
318
319 /**
320 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
321 * </p>
322 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
323 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
324 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
325 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
326 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
327 * @return a stream of matches represented as a Match object.
328 *
329 */
330 public Stream<CpsApplications.Match> streamAllMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
331 return rawStreamAllMatches(new Object[]{pCps, pAppInstance});
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 pCps the fixed value of pattern parameter Cps, or null if not bound.
338 * @param pAppInstance the fixed value of pattern parameter AppInstance, 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<CpsApplications.Match> getOneArbitraryMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
343 return rawGetOneArbitraryMatch(new Object[]{pCps, pAppInstance});
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 pCps the fixed value of pattern parameter Cps, or null if not bound.
350 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
351 * @return true if the input is a valid (partial) match of the pattern.
352 *
353 */
354 public boolean hasMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
355 return rawHasMatch(new Object[]{pCps, pAppInstance});
356 }
357
358 /**
359 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
360 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
361 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
362 * @return the number of pattern matches found.
363 *
364 */
365 public int countMatches(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
366 return rawCountMatches(new Object[]{pCps, pAppInstance});
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 pCps the fixed value of pattern parameter Cps, or null if not bound.
373 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
374 * @param processor the action that will process the selected match.
375 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
376 *
377 */
378 public boolean forOneArbitraryMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance, final Consumer<? super CpsApplications.Match> processor) {
379 return rawForOneArbitraryMatch(new Object[]{pCps, pAppInstance}, processor);
380 }
381
382 /**
383 * Returns a new (partial) match.
384 * This can be used e.g. to call the matcher with a partial match.
385 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
386 * @param pCps the fixed value of pattern parameter Cps, or null if not bound.
387 * @param pAppInstance the fixed value of pattern parameter AppInstance, or null if not bound.
388 * @return the (partial) match object.
389 *
390 */
391 public CpsApplications.Match newMatch(final CyberPhysicalSystem pCps, final ApplicationInstance pAppInstance) {
392 return CpsApplications.Match.newMatch(pCps, pAppInstance);
393 }
394
395 /**
396 * Retrieve the set of values that occur in matches for Cps.
397 * @return the Set of all values or empty set if there are no matches
398 *
399 */
400 protected Stream<CyberPhysicalSystem> rawStreamAllValuesOfCps(final Object[] parameters) {
401 return rawStreamAllValues(POSITION_CPS, parameters).map(CyberPhysicalSystem.class::cast);
402 }
403
404 /**
405 * Retrieve the set of values that occur in matches for Cps.
406 * @return the Set of all values or empty set if there are no matches
407 *
408 */
409 public Set<CyberPhysicalSystem> getAllValuesOfCps() {
410 return rawStreamAllValuesOfCps(emptyArray()).collect(Collectors.toSet());
411 }
412
413 /**
414 * Retrieve the set of values that occur in matches for Cps.
415 * @return the Set of all values or empty set if there are no matches
416 *
417 */
418 public Stream<CyberPhysicalSystem> streamAllValuesOfCps() {
419 return rawStreamAllValuesOfCps(emptyArray());
420 }
421
422 /**
423 * Retrieve the set of values that occur in matches for Cps.
424 * </p>
425 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
426 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
427 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
428 *
429 * @return the Stream of all values or empty set if there are no matches
430 *
431 */
432 public Stream<CyberPhysicalSystem> streamAllValuesOfCps(final CpsApplications.Match partialMatch) {
433 return rawStreamAllValuesOfCps(partialMatch.toArray());
434 }
435
436 /**
437 * Retrieve the set of values that occur in matches for Cps.
438 * </p>
439 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
440 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
441 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
442 *
443 * @return the Stream of all values or empty set if there are no matches
444 *
445 */
446 public Stream<CyberPhysicalSystem> streamAllValuesOfCps(final ApplicationInstance pAppInstance) {
447 return rawStreamAllValuesOfCps(new Object[]{null, pAppInstance});
448 }
449
450 /**
451 * Retrieve the set of values that occur in matches for Cps.
452 * @return the Set of all values or empty set if there are no matches
453 *
454 */
455 public Set<CyberPhysicalSystem> getAllValuesOfCps(final CpsApplications.Match partialMatch) {
456 return rawStreamAllValuesOfCps(partialMatch.toArray()).collect(Collectors.toSet());
457 }
458
459 /**
460 * Retrieve the set of values that occur in matches for Cps.
461 * @return the Set of all values or empty set if there are no matches
462 *
463 */
464 public Set<CyberPhysicalSystem> getAllValuesOfCps(final ApplicationInstance pAppInstance) {
465 return rawStreamAllValuesOfCps(new Object[]{null, pAppInstance}).collect(Collectors.toSet());
466 }
467
468 /**
469 * Retrieve the set of values that occur in matches for AppInstance.
470 * @return the Set of all values or empty set if there are no matches
471 *
472 */
473 protected Stream<ApplicationInstance> rawStreamAllValuesOfAppInstance(final Object[] parameters) {
474 return rawStreamAllValues(POSITION_APPINSTANCE, parameters).map(ApplicationInstance.class::cast);
475 }
476
477 /**
478 * Retrieve the set of values that occur in matches for AppInstance.
479 * @return the Set of all values or empty set if there are no matches
480 *
481 */
482 public Set<ApplicationInstance> getAllValuesOfAppInstance() {
483 return rawStreamAllValuesOfAppInstance(emptyArray()).collect(Collectors.toSet());
484 }
485
486 /**
487 * Retrieve the set of values that occur in matches for AppInstance.
488 * @return the Set of all values or empty set if there are no matches
489 *
490 */
491 public Stream<ApplicationInstance> streamAllValuesOfAppInstance() {
492 return rawStreamAllValuesOfAppInstance(emptyArray());
493 }
494
495 /**
496 * Retrieve the set of values that occur in matches for AppInstance.
497 * </p>
498 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
499 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
500 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
501 *
502 * @return the Stream of all values or empty set if there are no matches
503 *
504 */
505 public Stream<ApplicationInstance> streamAllValuesOfAppInstance(final CpsApplications.Match partialMatch) {
506 return rawStreamAllValuesOfAppInstance(partialMatch.toArray());
507 }
508
509 /**
510 * Retrieve the set of values that occur in matches for AppInstance.
511 * </p>
512 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
513 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
514 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
515 *
516 * @return the Stream of all values or empty set if there are no matches
517 *
518 */
519 public Stream<ApplicationInstance> streamAllValuesOfAppInstance(final CyberPhysicalSystem pCps) {
520 return rawStreamAllValuesOfAppInstance(new Object[]{pCps, null});
521 }
522
523 /**
524 * Retrieve the set of values that occur in matches for AppInstance.
525 * @return the Set of all values or empty set if there are no matches
526 *
527 */
528 public Set<ApplicationInstance> getAllValuesOfAppInstance(final CpsApplications.Match partialMatch) {
529 return rawStreamAllValuesOfAppInstance(partialMatch.toArray()).collect(Collectors.toSet());
530 }
531
532 /**
533 * Retrieve the set of values that occur in matches for AppInstance.
534 * @return the Set of all values or empty set if there are no matches
535 *
536 */
537 public Set<ApplicationInstance> getAllValuesOfAppInstance(final CyberPhysicalSystem pCps) {
538 return rawStreamAllValuesOfAppInstance(new Object[]{pCps, null}).collect(Collectors.toSet());
539 }
540
541 @Override
542 protected CpsApplications.Match tupleToMatch(final Tuple t) {
543 try {
544 return CpsApplications.Match.newMatch((CyberPhysicalSystem) t.get(POSITION_CPS), (ApplicationInstance) t.get(POSITION_APPINSTANCE));
545 } catch(ClassCastException e) {
546 LOGGER.error("Element(s) in tuple not properly typed!",e);
547 return null;
548 }
549 }
550
551 @Override
552 protected CpsApplications.Match arrayToMatch(final Object[] match) {
553 try {
554 return CpsApplications.Match.newMatch((CyberPhysicalSystem) match[POSITION_CPS], (ApplicationInstance) match[POSITION_APPINSTANCE]);
555 } catch(ClassCastException e) {
556 LOGGER.error("Element(s) in array not properly typed!",e);
557 return null;
558 }
559 }
560
561 @Override
562 protected CpsApplications.Match arrayToMatchMutable(final Object[] match) {
563 try {
564 return CpsApplications.Match.newMutableMatch((CyberPhysicalSystem) match[POSITION_CPS], (ApplicationInstance) match[POSITION_APPINSTANCE]);
565 } catch(ClassCastException e) {
566 LOGGER.error("Element(s) in array not properly typed!",e);
567 return null;
568 }
569 }
570
571 /**
572 * @return the singleton instance of the query specification of this pattern
573 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
574 *
575 */
576 public static IQuerySpecification<CpsApplications.Matcher> querySpecification() {
577 return CpsApplications.instance();
578 }
579 }
580
581 private CpsApplications() {
582 super(GeneratedPQuery.INSTANCE);
583 }
584
585 /**
586 * @return the singleton instance of the query specification
587 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
588 *
589 */
590 public static CpsApplications instance() {
591 try{
592 return LazyHolder.INSTANCE;
593 } catch (ExceptionInInitializerError err) {
594 throw processInitializerError(err);
595 }
596 }
597
598 @Override
599 protected CpsApplications.Matcher instantiate(final ViatraQueryEngine engine) {
600 return CpsApplications.Matcher.on(engine);
601 }
602
603 @Override
604 public CpsApplications.Matcher instantiate() {
605 return CpsApplications.Matcher.create();
606 }
607
608 @Override
609 public CpsApplications.Match newEmptyMatch() {
610 return CpsApplications.Match.newEmptyMatch();
611 }
612
613 @Override
614 public CpsApplications.Match newMatch(final Object... parameters) {
615 return CpsApplications.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance) parameters[1]);
616 }
617
618 /**
619 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)} to be created
620 * <b>not</b> at the class load time of the outer class,
621 * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications (visibility: PUBLIC, simpleName: CpsApplications, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.CpsApplications, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
622 *
623 * <p> This workaround is required e.g. to support recursion.
624 *
625 */
626 private static class LazyHolder {
627 private static final CpsApplications INSTANCE = new CpsApplications();
628
629 /**
630 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
631 * This initialization order is required to support indirect recursion.
632 *
633 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
634 *
635 */
636 private static final Object STATIC_INITIALIZER = ensureInitialized();
637
638 public static Object ensureInitialized() {
639 INSTANCE.ensureInitializedInternal();
640 return null;
641 }
642 }
643
644 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
645 private static final CpsApplications.GeneratedPQuery INSTANCE = new GeneratedPQuery();
646
647 private final PParameter parameter_Cps = new PParameter("Cps", "hu.bme.mit.inf.dslreasoner.domains.cps.CyberPhysicalSystem", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "CyberPhysicalSystem")), PParameterDirection.INOUT);
648
649 private final PParameter parameter_AppInstance = new PParameter("AppInstance", "hu.bme.mit.inf.dslreasoner.domains.cps.ApplicationInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "ApplicationInstance")), PParameterDirection.INOUT);
650
651 private final List<PParameter> parameters = Arrays.asList(parameter_Cps, parameter_AppInstance);
652
653 private GeneratedPQuery() {
654 super(PVisibility.PUBLIC);
655 }
656
657 @Override
658 public String getFullyQualifiedName() {
659 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.cpsApplications";
660 }
661
662 @Override
663 public List<String> getParameterNames() {
664 return Arrays.asList("Cps","AppInstance");
665 }
666
667 @Override
668 public List<PParameter> getParameters() {
669 return parameters;
670 }
671
672 @Override
673 public Set<PBody> doGetContainedBodies() {
674 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
675 Set<PBody> bodies = new LinkedHashSet<>();
676 {
677 PBody body = new PBody(this);
678 PVariable var_Cps = body.getOrCreateVariableByName("Cps");
679 PVariable var_AppInstance = body.getOrCreateVariableByName("AppInstance");
680 new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem")));
681 new TypeConstraint(body, Tuples.flatTupleOf(var_AppInstance), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
682 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
683 new ExportedParameter(body, var_Cps, parameter_Cps),
684 new ExportedParameter(body, var_AppInstance, parameter_AppInstance)
685 ));
686 // CyberPhysicalSystem.applicationTypes.instances(Cps, AppInstance)
687 new TypeConstraint(body, Tuples.flatTupleOf(var_Cps), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "CyberPhysicalSystem")));
688 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
689 new TypeConstraint(body, Tuples.flatTupleOf(var_Cps, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "CyberPhysicalSystem", "applicationTypes")));
690 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationType")));
691 PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}");
692 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http://www.example.org/cps", "ApplicationType", "instances")));
693 new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "ApplicationInstance")));
694 new Equality(body, var__virtual_1_, var_AppInstance);
695 bodies.add(body);
696 }
697 {
698 PAnnotation annotation = new PAnnotation("QueryBasedFeature");
699 annotation.addAttribute("feature", "applications");
700 addAnnotation(annotation);
701 }
702 return bodies;
703 }
704 }
705}