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