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