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