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