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