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