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