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