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