aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.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/AverageFreeHddMetric.java')
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java554
1 files changed, 554 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java
new file mode 100644
index 00000000..607854bf
--- /dev/null
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/AverageFreeHddMetric.java
@@ -0,0 +1,554 @@
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.queries.internal.FreeHddPercentage;
7import java.util.Arrays;
8import java.util.Collection;
9import java.util.LinkedHashSet;
10import java.util.List;
11import java.util.Objects;
12import java.util.Optional;
13import java.util.Set;
14import java.util.function.Consumer;
15import java.util.stream.Collectors;
16import java.util.stream.Stream;
17import org.apache.log4j.Logger;
18import org.eclipse.viatra.query.runtime.api.IPatternMatch;
19import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
20import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
21import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
22import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
23import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
24import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
25import org.eclipse.viatra.query.runtime.matchers.aggregators.avg;
26import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
27import org.eclipse.viatra.query.runtime.matchers.context.common.JavaTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
29import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
30import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.AggregatorConstraint;
31import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality;
32import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
33import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.TypeFilterConstraint;
34import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
35import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
36import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
37import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
38import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
39import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
40
41/**
42 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
43 *
44 * <p>Original source:
45 * <code><pre>
46 * // Free HDD
47 *
48 * pattern averageFreeHddMetric(Average : java Double) {
49 * Average == avg find freeHddPercentage(_, #_);
50 * }
51 * </pre></code>
52 *
53 * @see Matcher
54 * @see Match
55 *
56 */
57@SuppressWarnings("all")
58public final class AverageFreeHddMetric extends BaseGeneratedEMFQuerySpecification<AverageFreeHddMetric.Matcher> {
59 /**
60 * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric pattern,
61 * to be used in conjunction with {@link Matcher}.
62 *
63 * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned.
64 * Each instance is a (possibly partial) substitution of pattern parameters,
65 * usable to represent a match of the pattern in the result of a query,
66 * or to specify the bound (fixed) input parameters when issuing a query.
67 *
68 * @see Matcher
69 *
70 */
71 public static abstract class Match extends BasePatternMatch {
72 private Double fAverage;
73
74 private static List<String> parameterNames = makeImmutableList("Average");
75
76 private Match(final Double pAverage) {
77 this.fAverage = pAverage;
78 }
79
80 @Override
81 public Object get(final String parameterName) {
82 switch(parameterName) {
83 case "Average": return this.fAverage;
84 default: return null;
85 }
86 }
87
88 @Override
89 public Object get(final int index) {
90 switch(index) {
91 case 0: return this.fAverage;
92 default: return null;
93 }
94 }
95
96 public Double getAverage() {
97 return this.fAverage;
98 }
99
100 @Override
101 public boolean set(final String parameterName, final Object newValue) {
102 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
103 if ("Average".equals(parameterName) ) {
104 this.fAverage = (Double) newValue;
105 return true;
106 }
107 return false;
108 }
109
110 public void setAverage(final Double pAverage) {
111 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
112 this.fAverage = pAverage;
113 }
114
115 @Override
116 public String patternName() {
117 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric";
118 }
119
120 @Override
121 public List<String> parameterNames() {
122 return AverageFreeHddMetric.Match.parameterNames;
123 }
124
125 @Override
126 public Object[] toArray() {
127 return new Object[]{fAverage};
128 }
129
130 @Override
131 public AverageFreeHddMetric.Match toImmutable() {
132 return isMutable() ? newMatch(fAverage) : this;
133 }
134
135 @Override
136 public String prettyPrint() {
137 StringBuilder result = new StringBuilder();
138 result.append("\"Average\"=" + prettyPrintValue(fAverage));
139 return result.toString();
140 }
141
142 @Override
143 public int hashCode() {
144 return Objects.hash(fAverage);
145 }
146
147 @Override
148 public boolean equals(final Object obj) {
149 if (this == obj)
150 return true;
151 if (obj == null) {
152 return false;
153 }
154 if ((obj instanceof AverageFreeHddMetric.Match)) {
155 AverageFreeHddMetric.Match other = (AverageFreeHddMetric.Match) obj;
156 return Objects.equals(fAverage, other.fAverage);
157 } else {
158 // this should be infrequent
159 if (!(obj instanceof IPatternMatch)) {
160 return false;
161 }
162 IPatternMatch otherSig = (IPatternMatch) obj;
163 return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray());
164 }
165 }
166
167 @Override
168 public AverageFreeHddMetric specification() {
169 return AverageFreeHddMetric.instance();
170 }
171
172 /**
173 * Returns an empty, mutable match.
174 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
175 *
176 * @return the empty match.
177 *
178 */
179 public static AverageFreeHddMetric.Match newEmptyMatch() {
180 return new Mutable(null);
181 }
182
183 /**
184 * Returns a mutable (partial) match.
185 * Fields of the mutable match can be filled to create a partial match, usable as matcher input.
186 *
187 * @param pAverage the fixed value of pattern parameter Average, or null if not bound.
188 * @return the new, mutable (partial) match object.
189 *
190 */
191 public static AverageFreeHddMetric.Match newMutableMatch(final Double pAverage) {
192 return new Mutable(pAverage);
193 }
194
195 /**
196 * Returns a new (partial) match.
197 * This can be used e.g. to call the matcher with a partial match.
198 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
199 * @param pAverage the fixed value of pattern parameter Average, or null if not bound.
200 * @return the (partial) match object.
201 *
202 */
203 public static AverageFreeHddMetric.Match newMatch(final Double pAverage) {
204 return new Immutable(pAverage);
205 }
206
207 private static final class Mutable extends AverageFreeHddMetric.Match {
208 Mutable(final Double pAverage) {
209 super(pAverage);
210 }
211
212 @Override
213 public boolean isMutable() {
214 return true;
215 }
216 }
217
218 private static final class Immutable extends AverageFreeHddMetric.Match {
219 Immutable(final Double pAverage) {
220 super(pAverage);
221 }
222
223 @Override
224 public boolean isMutable() {
225 return false;
226 }
227 }
228 }
229
230 /**
231 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric pattern,
232 * providing pattern-specific query methods.
233 *
234 * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)},
235 * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}.
236 *
237 * <p>Matches of the pattern will be represented as {@link Match}.
238 *
239 * <p>Original source:
240 * <code><pre>
241 * // Free HDD
242 *
243 * pattern averageFreeHddMetric(Average : java Double) {
244 * Average == avg find freeHddPercentage(_, #_);
245 * }
246 * </pre></code>
247 *
248 * @see Match
249 * @see AverageFreeHddMetric
250 *
251 */
252 public static class Matcher extends BaseMatcher<AverageFreeHddMetric.Match> {
253 /**
254 * Initializes the pattern matcher within an existing VIATRA Query engine.
255 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
256 *
257 * @param engine the existing VIATRA Query engine in which this matcher will be created.
258 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
259 *
260 */
261 public static AverageFreeHddMetric.Matcher on(final ViatraQueryEngine engine) {
262 // check if matcher already exists
263 Matcher matcher = engine.getExistingMatcher(querySpecification());
264 if (matcher == null) {
265 matcher = (Matcher)engine.getMatcher(querySpecification());
266 }
267 return matcher;
268 }
269
270 /**
271 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
272 * @return an initialized matcher
273 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
274 *
275 */
276 public static AverageFreeHddMetric.Matcher create() {
277 return new Matcher();
278 }
279
280 private static final int POSITION_AVERAGE = 0;
281
282 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(AverageFreeHddMetric.Matcher.class);
283
284 /**
285 * Initializes the pattern matcher within an existing VIATRA Query engine.
286 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
287 *
288 * @param engine the existing VIATRA Query engine in which this matcher will be created.
289 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
290 *
291 */
292 private Matcher() {
293 super(querySpecification());
294 }
295
296 /**
297 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
298 * @param pAverage the fixed value of pattern parameter Average, or null if not bound.
299 * @return matches represented as a Match object.
300 *
301 */
302 public Collection<AverageFreeHddMetric.Match> getAllMatches(final Double pAverage) {
303 return rawStreamAllMatches(new Object[]{pAverage}).collect(Collectors.toSet());
304 }
305
306 /**
307 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
308 * </p>
309 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
310 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
311 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
312 * @param pAverage the fixed value of pattern parameter Average, or null if not bound.
313 * @return a stream of matches represented as a Match object.
314 *
315 */
316 public Stream<AverageFreeHddMetric.Match> streamAllMatches(final Double pAverage) {
317 return rawStreamAllMatches(new Object[]{pAverage});
318 }
319
320 /**
321 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
322 * Neither determinism nor randomness of selection is guaranteed.
323 * @param pAverage the fixed value of pattern parameter Average, or null if not bound.
324 * @return a match represented as a Match object, or null if no match is found.
325 *
326 */
327 public Optional<AverageFreeHddMetric.Match> getOneArbitraryMatch(final Double pAverage) {
328 return rawGetOneArbitraryMatch(new Object[]{pAverage});
329 }
330
331 /**
332 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
333 * under any possible substitution of the unspecified parameters (if any).
334 * @param pAverage the fixed value of pattern parameter Average, or null if not bound.
335 * @return true if the input is a valid (partial) match of the pattern.
336 *
337 */
338 public boolean hasMatch(final Double pAverage) {
339 return rawHasMatch(new Object[]{pAverage});
340 }
341
342 /**
343 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
344 * @param pAverage the fixed value of pattern parameter Average, or null if not bound.
345 * @return the number of pattern matches found.
346 *
347 */
348 public int countMatches(final Double pAverage) {
349 return rawCountMatches(new Object[]{pAverage});
350 }
351
352 /**
353 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
354 * Neither determinism nor randomness of selection is guaranteed.
355 * @param pAverage the fixed value of pattern parameter Average, or null if not bound.
356 * @param processor the action that will process the selected match.
357 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
358 *
359 */
360 public boolean forOneArbitraryMatch(final Double pAverage, final Consumer<? super AverageFreeHddMetric.Match> processor) {
361 return rawForOneArbitraryMatch(new Object[]{pAverage}, processor);
362 }
363
364 /**
365 * Returns a new (partial) match.
366 * This can be used e.g. to call the matcher with a partial match.
367 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
368 * @param pAverage the fixed value of pattern parameter Average, or null if not bound.
369 * @return the (partial) match object.
370 *
371 */
372 public AverageFreeHddMetric.Match newMatch(final Double pAverage) {
373 return AverageFreeHddMetric.Match.newMatch(pAverage);
374 }
375
376 /**
377 * Retrieve the set of values that occur in matches for Average.
378 * @return the Set of all values or empty set if there are no matches
379 *
380 */
381 protected Stream<Double> rawStreamAllValuesOfAverage(final Object[] parameters) {
382 return rawStreamAllValues(POSITION_AVERAGE, parameters).map(Double.class::cast);
383 }
384
385 /**
386 * Retrieve the set of values that occur in matches for Average.
387 * @return the Set of all values or empty set if there are no matches
388 *
389 */
390 public Set<Double> getAllValuesOfAverage() {
391 return rawStreamAllValuesOfAverage(emptyArray()).collect(Collectors.toSet());
392 }
393
394 /**
395 * Retrieve the set of values that occur in matches for Average.
396 * @return the Set of all values or empty set if there are no matches
397 *
398 */
399 public Stream<Double> streamAllValuesOfAverage() {
400 return rawStreamAllValuesOfAverage(emptyArray());
401 }
402
403 @Override
404 protected AverageFreeHddMetric.Match tupleToMatch(final Tuple t) {
405 try {
406 return AverageFreeHddMetric.Match.newMatch((Double) t.get(POSITION_AVERAGE));
407 } catch(ClassCastException e) {
408 LOGGER.error("Element(s) in tuple not properly typed!",e);
409 return null;
410 }
411 }
412
413 @Override
414 protected AverageFreeHddMetric.Match arrayToMatch(final Object[] match) {
415 try {
416 return AverageFreeHddMetric.Match.newMatch((Double) match[POSITION_AVERAGE]);
417 } catch(ClassCastException e) {
418 LOGGER.error("Element(s) in array not properly typed!",e);
419 return null;
420 }
421 }
422
423 @Override
424 protected AverageFreeHddMetric.Match arrayToMatchMutable(final Object[] match) {
425 try {
426 return AverageFreeHddMetric.Match.newMutableMatch((Double) match[POSITION_AVERAGE]);
427 } catch(ClassCastException e) {
428 LOGGER.error("Element(s) in array not properly typed!",e);
429 return null;
430 }
431 }
432
433 /**
434 * @return the singleton instance of the query specification of this pattern
435 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
436 *
437 */
438 public static IQuerySpecification<AverageFreeHddMetric.Matcher> querySpecification() {
439 return AverageFreeHddMetric.instance();
440 }
441 }
442
443 private AverageFreeHddMetric() {
444 super(GeneratedPQuery.INSTANCE);
445 }
446
447 /**
448 * @return the singleton instance of the query specification
449 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
450 *
451 */
452 public static AverageFreeHddMetric instance() {
453 try{
454 return LazyHolder.INSTANCE;
455 } catch (ExceptionInInitializerError err) {
456 throw processInitializerError(err);
457 }
458 }
459
460 @Override
461 protected AverageFreeHddMetric.Matcher instantiate(final ViatraQueryEngine engine) {
462 return AverageFreeHddMetric.Matcher.on(engine);
463 }
464
465 @Override
466 public AverageFreeHddMetric.Matcher instantiate() {
467 return AverageFreeHddMetric.Matcher.create();
468 }
469
470 @Override
471 public AverageFreeHddMetric.Match newEmptyMatch() {
472 return AverageFreeHddMetric.Match.newEmptyMatch();
473 }
474
475 @Override
476 public AverageFreeHddMetric.Match newMatch(final Object... parameters) {
477 return AverageFreeHddMetric.Match.newMatch((java.lang.Double) parameters[0]);
478 }
479
480 /**
481 * Inner class allowing the singleton instance of {@link AverageFreeHddMetric} to be created
482 * <b>not</b> at the class load time of the outer class,
483 * but rather at the first call to {@link AverageFreeHddMetric#instance()}.
484 *
485 * <p> This workaround is required e.g. to support recursion.
486 *
487 */
488 private static class LazyHolder {
489 private static final AverageFreeHddMetric INSTANCE = new AverageFreeHddMetric();
490
491 /**
492 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
493 * This initialization order is required to support indirect recursion.
494 *
495 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
496 *
497 */
498 private static final Object STATIC_INITIALIZER = ensureInitialized();
499
500 public static Object ensureInitialized() {
501 INSTANCE.ensureInitializedInternal();
502 return null;
503 }
504 }
505
506 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
507 private static final AverageFreeHddMetric.GeneratedPQuery INSTANCE = new GeneratedPQuery();
508
509 private final PParameter parameter_Average = new PParameter("Average", "java.lang.Double", new JavaTransitiveInstancesKey(java.lang.Double.class), PParameterDirection.INOUT);
510
511 private final List<PParameter> parameters = Arrays.asList(parameter_Average);
512
513 private GeneratedPQuery() {
514 super(PVisibility.PUBLIC);
515 }
516
517 @Override
518 public String getFullyQualifiedName() {
519 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.averageFreeHddMetric";
520 }
521
522 @Override
523 public List<String> getParameterNames() {
524 return Arrays.asList("Average");
525 }
526
527 @Override
528 public List<PParameter> getParameters() {
529 return parameters;
530 }
531
532 @Override
533 public Set<PBody> doGetContainedBodies() {
534 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
535 Set<PBody> bodies = new LinkedHashSet<>();
536 {
537 PBody body = new PBody(this);
538 PVariable var_Average = body.getOrCreateVariableByName("Average");
539 PVariable var___0_ = body.getOrCreateVariableByName("_<0>");
540 PVariable var___1_ = body.getOrCreateVariableByName("_<1>");
541 new TypeFilterConstraint(body, Tuples.flatTupleOf(var_Average), new JavaTransitiveInstancesKey(java.lang.Double.class));
542 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
543 new ExportedParameter(body, var_Average, parameter_Average)
544 ));
545 // Average == avg find freeHddPercentage(_, #_)
546 PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}");
547 new AggregatorConstraint(new avg().getAggregatorLogic(Double.class), body, Tuples.flatTupleOf(var___0_, var___1_), FreeHddPercentage.instance().getInternalQueryRepresentation(), var__virtual_0_, 1);
548 new Equality(body, var_Average, var__virtual_0_);
549 bodies.add(body);
550 }
551 return bodies;
552 }
553 }
554}