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