diff options
author | 2020-05-07 19:12:45 +0200 | |
---|---|---|
committer | 2020-05-07 19:22:45 +0200 | |
commit | 89235248d109ec015cc483188a7c4167c0deef77 (patch) | |
tree | a2f0901b664df37992f5b88213bd117ebdfffdb5 /Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/ContentInNotLive.java | |
parent | multiple object additions fixes (diff) | |
download | VIATRA-Generator-89235248d109ec015cc483188a7c4167c0deef77.tar.gz VIATRA-Generator-89235248d109ec015cc483188a7c4167c0deef77.tar.zst VIATRA-Generator-89235248d109ec015cc483188a7c4167c0deef77.zip |
Rebuild with Eclipse 2020-03
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/ContentInNotLive.java')
-rw-r--r-- | Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/ContentInNotLive.java | 752 |
1 files changed, 752 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/ContentInNotLive.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/ContentInNotLive.java new file mode 100644 index 00000000..ef0aaaf3 --- /dev/null +++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.alloyexamples/src-gen/hu/bme/mit/inf/dslreasoner/domains/alloyexamples/ContentInNotLive.java | |||
@@ -0,0 +1,752 @@ | |||
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.Filesystem.Dir; | ||
7 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject; | ||
8 | import hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Live; | ||
9 | import java.util.Arrays; | ||
10 | import java.util.Collection; | ||
11 | import java.util.LinkedHashSet; | ||
12 | import java.util.List; | ||
13 | import java.util.Objects; | ||
14 | import java.util.Optional; | ||
15 | import java.util.Set; | ||
16 | import java.util.function.Consumer; | ||
17 | import java.util.stream.Collectors; | ||
18 | import java.util.stream.Stream; | ||
19 | import org.apache.log4j.Logger; | ||
20 | import org.eclipse.emf.ecore.EClass; | ||
21 | import org.eclipse.viatra.query.runtime.api.IPatternMatch; | ||
22 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
25 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
26 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
27 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.NegativePatternCall; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint; | ||
39 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter; | ||
40 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection; | ||
41 | import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility; | ||
42 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple; | ||
43 | import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples; | ||
44 | import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil; | ||
45 | |||
46 | /** | ||
47 | * A pattern-specific query specification that can instantiate Matcher in a type-safe way. | ||
48 | * | ||
49 | * <p>Original source: | ||
50 | * <code><pre> | ||
51 | * {@literal @}Constraint(key={child}, severity="error", message="error") | ||
52 | * pattern contentInNotLive(parent : Dir, child: FSObject) { | ||
53 | * Dir.contents(parent,child); | ||
54 | * neg find live(_,parent); | ||
55 | * } or { | ||
56 | * Dir.contents(parent,child); | ||
57 | * neg find live(_,child); | ||
58 | * } | ||
59 | * </pre></code> | ||
60 | * | ||
61 | * @see Matcher | ||
62 | * @see Match | ||
63 | * | ||
64 | */ | ||
65 | @SuppressWarnings("all") | ||
66 | public final class ContentInNotLive extends BaseGeneratedEMFQuerySpecification<ContentInNotLive.Matcher> { | ||
67 | /** | ||
68 | * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.contentInNotLive pattern, | ||
69 | * to be used in conjunction with {@link Matcher}. | ||
70 | * | ||
71 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
72 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
73 | * usable to represent a match of the pattern in the result of a query, | ||
74 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
75 | * | ||
76 | * @see Matcher | ||
77 | * | ||
78 | */ | ||
79 | public static abstract class Match extends BasePatternMatch { | ||
80 | private Dir fParent; | ||
81 | |||
82 | private FSObject fChild; | ||
83 | |||
84 | private static List<String> parameterNames = makeImmutableList("parent", "child"); | ||
85 | |||
86 | private Match(final Dir pParent, final FSObject pChild) { | ||
87 | this.fParent = pParent; | ||
88 | this.fChild = pChild; | ||
89 | } | ||
90 | |||
91 | @Override | ||
92 | public Object get(final String parameterName) { | ||
93 | switch(parameterName) { | ||
94 | case "parent": return this.fParent; | ||
95 | case "child": return this.fChild; | ||
96 | default: return null; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | @Override | ||
101 | public Object get(final int index) { | ||
102 | switch(index) { | ||
103 | case 0: return this.fParent; | ||
104 | case 1: return this.fChild; | ||
105 | default: return null; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | public Dir getParent() { | ||
110 | return this.fParent; | ||
111 | } | ||
112 | |||
113 | public FSObject getChild() { | ||
114 | return this.fChild; | ||
115 | } | ||
116 | |||
117 | @Override | ||
118 | public boolean set(final String parameterName, final Object newValue) { | ||
119 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
120 | if ("parent".equals(parameterName) ) { | ||
121 | this.fParent = (Dir) newValue; | ||
122 | return true; | ||
123 | } | ||
124 | if ("child".equals(parameterName) ) { | ||
125 | this.fChild = (FSObject) newValue; | ||
126 | return true; | ||
127 | } | ||
128 | return false; | ||
129 | } | ||
130 | |||
131 | public void setParent(final Dir pParent) { | ||
132 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
133 | this.fParent = pParent; | ||
134 | } | ||
135 | |||
136 | public void setChild(final FSObject pChild) { | ||
137 | if (!isMutable()) throw new java.lang.UnsupportedOperationException(); | ||
138 | this.fChild = pChild; | ||
139 | } | ||
140 | |||
141 | @Override | ||
142 | public String patternName() { | ||
143 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.contentInNotLive"; | ||
144 | } | ||
145 | |||
146 | @Override | ||
147 | public List<String> parameterNames() { | ||
148 | return ContentInNotLive.Match.parameterNames; | ||
149 | } | ||
150 | |||
151 | @Override | ||
152 | public Object[] toArray() { | ||
153 | return new Object[]{fParent, fChild}; | ||
154 | } | ||
155 | |||
156 | @Override | ||
157 | public ContentInNotLive.Match toImmutable() { | ||
158 | return isMutable() ? newMatch(fParent, fChild) : this; | ||
159 | } | ||
160 | |||
161 | @Override | ||
162 | public String prettyPrint() { | ||
163 | StringBuilder result = new StringBuilder(); | ||
164 | result.append("\"parent\"=" + prettyPrintValue(fParent) + ", "); | ||
165 | result.append("\"child\"=" + prettyPrintValue(fChild)); | ||
166 | return result.toString(); | ||
167 | } | ||
168 | |||
169 | @Override | ||
170 | public int hashCode() { | ||
171 | return Objects.hash(fParent, fChild); | ||
172 | } | ||
173 | |||
174 | @Override | ||
175 | public boolean equals(final Object obj) { | ||
176 | if (this == obj) | ||
177 | return true; | ||
178 | if (obj == null) { | ||
179 | return false; | ||
180 | } | ||
181 | if ((obj instanceof ContentInNotLive.Match)) { | ||
182 | ContentInNotLive.Match other = (ContentInNotLive.Match) obj; | ||
183 | return Objects.equals(fParent, other.fParent) && Objects.equals(fChild, other.fChild); | ||
184 | } else { | ||
185 | // this should be infrequent | ||
186 | if (!(obj instanceof IPatternMatch)) { | ||
187 | return false; | ||
188 | } | ||
189 | IPatternMatch otherSig = (IPatternMatch) obj; | ||
190 | return Objects.equals(specification(), otherSig.specification()) && Arrays.deepEquals(toArray(), otherSig.toArray()); | ||
191 | } | ||
192 | } | ||
193 | |||
194 | @Override | ||
195 | public ContentInNotLive specification() { | ||
196 | return ContentInNotLive.instance(); | ||
197 | } | ||
198 | |||
199 | /** | ||
200 | * Returns an empty, mutable match. | ||
201 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
202 | * | ||
203 | * @return the empty match. | ||
204 | * | ||
205 | */ | ||
206 | public static ContentInNotLive.Match newEmptyMatch() { | ||
207 | return new Mutable(null, null); | ||
208 | } | ||
209 | |||
210 | /** | ||
211 | * Returns a mutable (partial) match. | ||
212 | * Fields of the mutable match can be filled to create a partial match, usable as matcher input. | ||
213 | * | ||
214 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
215 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
216 | * @return the new, mutable (partial) match object. | ||
217 | * | ||
218 | */ | ||
219 | public static ContentInNotLive.Match newMutableMatch(final Dir pParent, final FSObject pChild) { | ||
220 | return new Mutable(pParent, pChild); | ||
221 | } | ||
222 | |||
223 | /** | ||
224 | * Returns a new (partial) match. | ||
225 | * This can be used e.g. to call the matcher with a partial match. | ||
226 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
227 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
228 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
229 | * @return the (partial) match object. | ||
230 | * | ||
231 | */ | ||
232 | public static ContentInNotLive.Match newMatch(final Dir pParent, final FSObject pChild) { | ||
233 | return new Immutable(pParent, pChild); | ||
234 | } | ||
235 | |||
236 | private static final class Mutable extends ContentInNotLive.Match { | ||
237 | Mutable(final Dir pParent, final FSObject pChild) { | ||
238 | super(pParent, pChild); | ||
239 | } | ||
240 | |||
241 | @Override | ||
242 | public boolean isMutable() { | ||
243 | return true; | ||
244 | } | ||
245 | } | ||
246 | |||
247 | private static final class Immutable extends ContentInNotLive.Match { | ||
248 | Immutable(final Dir pParent, final FSObject pChild) { | ||
249 | super(pParent, pChild); | ||
250 | } | ||
251 | |||
252 | @Override | ||
253 | public boolean isMutable() { | ||
254 | return false; | ||
255 | } | ||
256 | } | ||
257 | } | ||
258 | |||
259 | /** | ||
260 | * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.alloyexamples.contentInNotLive pattern, | ||
261 | * providing pattern-specific query methods. | ||
262 | * | ||
263 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
264 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
265 | * | ||
266 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
267 | * | ||
268 | * <p>Original source: | ||
269 | * <code><pre> | ||
270 | * {@literal @}Constraint(key={child}, severity="error", message="error") | ||
271 | * pattern contentInNotLive(parent : Dir, child: FSObject) { | ||
272 | * Dir.contents(parent,child); | ||
273 | * neg find live(_,parent); | ||
274 | * } or { | ||
275 | * Dir.contents(parent,child); | ||
276 | * neg find live(_,child); | ||
277 | * } | ||
278 | * </pre></code> | ||
279 | * | ||
280 | * @see Match | ||
281 | * @see ContentInNotLive | ||
282 | * | ||
283 | */ | ||
284 | public static class Matcher extends BaseMatcher<ContentInNotLive.Match> { | ||
285 | /** | ||
286 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
287 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
288 | * | ||
289 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
290 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
291 | * | ||
292 | */ | ||
293 | public static ContentInNotLive.Matcher on(final ViatraQueryEngine engine) { | ||
294 | // check if matcher already exists | ||
295 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
296 | if (matcher == null) { | ||
297 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
298 | } | ||
299 | return matcher; | ||
300 | } | ||
301 | |||
302 | /** | ||
303 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
304 | * @return an initialized matcher | ||
305 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
306 | * | ||
307 | */ | ||
308 | public static ContentInNotLive.Matcher create() { | ||
309 | return new Matcher(); | ||
310 | } | ||
311 | |||
312 | private static final int POSITION_PARENT = 0; | ||
313 | |||
314 | private static final int POSITION_CHILD = 1; | ||
315 | |||
316 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(ContentInNotLive.Matcher.class); | ||
317 | |||
318 | /** | ||
319 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
320 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
321 | * | ||
322 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
323 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
324 | * | ||
325 | */ | ||
326 | private Matcher() { | ||
327 | super(querySpecification()); | ||
328 | } | ||
329 | |||
330 | /** | ||
331 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
332 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
333 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
334 | * @return matches represented as a Match object. | ||
335 | * | ||
336 | */ | ||
337 | public Collection<ContentInNotLive.Match> getAllMatches(final Dir pParent, final FSObject pChild) { | ||
338 | return rawStreamAllMatches(new Object[]{pParent, pChild}).collect(Collectors.toSet()); | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
343 | * </p> | ||
344 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
345 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
346 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
347 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
348 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
349 | * @return a stream of matches represented as a Match object. | ||
350 | * | ||
351 | */ | ||
352 | public Stream<ContentInNotLive.Match> streamAllMatches(final Dir pParent, final FSObject pChild) { | ||
353 | return rawStreamAllMatches(new Object[]{pParent, pChild}); | ||
354 | } | ||
355 | |||
356 | /** | ||
357 | * Returns 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 pParent the fixed value of pattern parameter parent, or null if not bound. | ||
360 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
361 | * @return a match represented as a Match object, or null if no match is found. | ||
362 | * | ||
363 | */ | ||
364 | public Optional<ContentInNotLive.Match> getOneArbitraryMatch(final Dir pParent, final FSObject pChild) { | ||
365 | return rawGetOneArbitraryMatch(new Object[]{pParent, pChild}); | ||
366 | } | ||
367 | |||
368 | /** | ||
369 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
370 | * under any possible substitution of the unspecified parameters (if any). | ||
371 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
372 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
373 | * @return true if the input is a valid (partial) match of the pattern. | ||
374 | * | ||
375 | */ | ||
376 | public boolean hasMatch(final Dir pParent, final FSObject pChild) { | ||
377 | return rawHasMatch(new Object[]{pParent, pChild}); | ||
378 | } | ||
379 | |||
380 | /** | ||
381 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
382 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
383 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
384 | * @return the number of pattern matches found. | ||
385 | * | ||
386 | */ | ||
387 | public int countMatches(final Dir pParent, final FSObject pChild) { | ||
388 | return rawCountMatches(new Object[]{pParent, pChild}); | ||
389 | } | ||
390 | |||
391 | /** | ||
392 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
393 | * Neither determinism nor randomness of selection is guaranteed. | ||
394 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
395 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
396 | * @param processor the action that will process the selected match. | ||
397 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
398 | * | ||
399 | */ | ||
400 | public boolean forOneArbitraryMatch(final Dir pParent, final FSObject pChild, final Consumer<? super ContentInNotLive.Match> processor) { | ||
401 | return rawForOneArbitraryMatch(new Object[]{pParent, pChild}, processor); | ||
402 | } | ||
403 | |||
404 | /** | ||
405 | * Returns a new (partial) match. | ||
406 | * This can be used e.g. to call the matcher with a partial match. | ||
407 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
408 | * @param pParent the fixed value of pattern parameter parent, or null if not bound. | ||
409 | * @param pChild the fixed value of pattern parameter child, or null if not bound. | ||
410 | * @return the (partial) match object. | ||
411 | * | ||
412 | */ | ||
413 | public ContentInNotLive.Match newMatch(final Dir pParent, final FSObject pChild) { | ||
414 | return ContentInNotLive.Match.newMatch(pParent, pChild); | ||
415 | } | ||
416 | |||
417 | /** | ||
418 | * Retrieve the set of values that occur in matches for parent. | ||
419 | * @return the Set of all values or empty set if there are no matches | ||
420 | * | ||
421 | */ | ||
422 | protected Stream<Dir> rawStreamAllValuesOfparent(final Object[] parameters) { | ||
423 | return rawStreamAllValues(POSITION_PARENT, parameters).map(Dir.class::cast); | ||
424 | } | ||
425 | |||
426 | /** | ||
427 | * Retrieve the set of values that occur in matches for parent. | ||
428 | * @return the Set of all values or empty set if there are no matches | ||
429 | * | ||
430 | */ | ||
431 | public Set<Dir> getAllValuesOfparent() { | ||
432 | return rawStreamAllValuesOfparent(emptyArray()).collect(Collectors.toSet()); | ||
433 | } | ||
434 | |||
435 | /** | ||
436 | * Retrieve the set of values that occur in matches for parent. | ||
437 | * @return the Set of all values or empty set if there are no matches | ||
438 | * | ||
439 | */ | ||
440 | public Stream<Dir> streamAllValuesOfparent() { | ||
441 | return rawStreamAllValuesOfparent(emptyArray()); | ||
442 | } | ||
443 | |||
444 | /** | ||
445 | * Retrieve the set of values that occur in matches for parent. | ||
446 | * </p> | ||
447 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
448 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
449 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
450 | * | ||
451 | * @return the Stream of all values or empty set if there are no matches | ||
452 | * | ||
453 | */ | ||
454 | public Stream<Dir> streamAllValuesOfparent(final ContentInNotLive.Match partialMatch) { | ||
455 | return rawStreamAllValuesOfparent(partialMatch.toArray()); | ||
456 | } | ||
457 | |||
458 | /** | ||
459 | * Retrieve the set of values that occur in matches for parent. | ||
460 | * </p> | ||
461 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
462 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
463 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
464 | * | ||
465 | * @return the Stream of all values or empty set if there are no matches | ||
466 | * | ||
467 | */ | ||
468 | public Stream<Dir> streamAllValuesOfparent(final FSObject pChild) { | ||
469 | return rawStreamAllValuesOfparent(new Object[]{null, pChild}); | ||
470 | } | ||
471 | |||
472 | /** | ||
473 | * Retrieve the set of values that occur in matches for parent. | ||
474 | * @return the Set of all values or empty set if there are no matches | ||
475 | * | ||
476 | */ | ||
477 | public Set<Dir> getAllValuesOfparent(final ContentInNotLive.Match partialMatch) { | ||
478 | return rawStreamAllValuesOfparent(partialMatch.toArray()).collect(Collectors.toSet()); | ||
479 | } | ||
480 | |||
481 | /** | ||
482 | * Retrieve the set of values that occur in matches for parent. | ||
483 | * @return the Set of all values or empty set if there are no matches | ||
484 | * | ||
485 | */ | ||
486 | public Set<Dir> getAllValuesOfparent(final FSObject pChild) { | ||
487 | return rawStreamAllValuesOfparent(new Object[]{null, pChild}).collect(Collectors.toSet()); | ||
488 | } | ||
489 | |||
490 | /** | ||
491 | * Retrieve the set of values that occur in matches for child. | ||
492 | * @return the Set of all values or empty set if there are no matches | ||
493 | * | ||
494 | */ | ||
495 | protected Stream<FSObject> rawStreamAllValuesOfchild(final Object[] parameters) { | ||
496 | return rawStreamAllValues(POSITION_CHILD, parameters).map(FSObject.class::cast); | ||
497 | } | ||
498 | |||
499 | /** | ||
500 | * Retrieve the set of values that occur in matches for child. | ||
501 | * @return the Set of all values or empty set if there are no matches | ||
502 | * | ||
503 | */ | ||
504 | public Set<FSObject> getAllValuesOfchild() { | ||
505 | return rawStreamAllValuesOfchild(emptyArray()).collect(Collectors.toSet()); | ||
506 | } | ||
507 | |||
508 | /** | ||
509 | * Retrieve the set of values that occur in matches for child. | ||
510 | * @return the Set of all values or empty set if there are no matches | ||
511 | * | ||
512 | */ | ||
513 | public Stream<FSObject> streamAllValuesOfchild() { | ||
514 | return rawStreamAllValuesOfchild(emptyArray()); | ||
515 | } | ||
516 | |||
517 | /** | ||
518 | * Retrieve the set of values that occur in matches for child. | ||
519 | * </p> | ||
520 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
521 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
522 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
523 | * | ||
524 | * @return the Stream of all values or empty set if there are no matches | ||
525 | * | ||
526 | */ | ||
527 | public Stream<FSObject> streamAllValuesOfchild(final ContentInNotLive.Match partialMatch) { | ||
528 | return rawStreamAllValuesOfchild(partialMatch.toArray()); | ||
529 | } | ||
530 | |||
531 | /** | ||
532 | * Retrieve the set of values that occur in matches for child. | ||
533 | * </p> | ||
534 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
535 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
536 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
537 | * | ||
538 | * @return the Stream of all values or empty set if there are no matches | ||
539 | * | ||
540 | */ | ||
541 | public Stream<FSObject> streamAllValuesOfchild(final Dir pParent) { | ||
542 | return rawStreamAllValuesOfchild(new Object[]{pParent, null}); | ||
543 | } | ||
544 | |||
545 | /** | ||
546 | * Retrieve the set of values that occur in matches for child. | ||
547 | * @return the Set of all values or empty set if there are no matches | ||
548 | * | ||
549 | */ | ||
550 | public Set<FSObject> getAllValuesOfchild(final ContentInNotLive.Match partialMatch) { | ||
551 | return rawStreamAllValuesOfchild(partialMatch.toArray()).collect(Collectors.toSet()); | ||
552 | } | ||
553 | |||
554 | /** | ||
555 | * Retrieve the set of values that occur in matches for child. | ||
556 | * @return the Set of all values or empty set if there are no matches | ||
557 | * | ||
558 | */ | ||
559 | public Set<FSObject> getAllValuesOfchild(final Dir pParent) { | ||
560 | return rawStreamAllValuesOfchild(new Object[]{pParent, null}).collect(Collectors.toSet()); | ||
561 | } | ||
562 | |||
563 | @Override | ||
564 | protected ContentInNotLive.Match tupleToMatch(final Tuple t) { | ||
565 | try { | ||
566 | return ContentInNotLive.Match.newMatch((Dir) t.get(POSITION_PARENT), (FSObject) t.get(POSITION_CHILD)); | ||
567 | } catch(ClassCastException e) { | ||
568 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
569 | return null; | ||
570 | } | ||
571 | } | ||
572 | |||
573 | @Override | ||
574 | protected ContentInNotLive.Match arrayToMatch(final Object[] match) { | ||
575 | try { | ||
576 | return ContentInNotLive.Match.newMatch((Dir) match[POSITION_PARENT], (FSObject) match[POSITION_CHILD]); | ||
577 | } catch(ClassCastException e) { | ||
578 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
579 | return null; | ||
580 | } | ||
581 | } | ||
582 | |||
583 | @Override | ||
584 | protected ContentInNotLive.Match arrayToMatchMutable(final Object[] match) { | ||
585 | try { | ||
586 | return ContentInNotLive.Match.newMutableMatch((Dir) match[POSITION_PARENT], (FSObject) match[POSITION_CHILD]); | ||
587 | } catch(ClassCastException e) { | ||
588 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
589 | return null; | ||
590 | } | ||
591 | } | ||
592 | |||
593 | /** | ||
594 | * @return the singleton instance of the query specification of this pattern | ||
595 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
596 | * | ||
597 | */ | ||
598 | public static IQuerySpecification<ContentInNotLive.Matcher> querySpecification() { | ||
599 | return ContentInNotLive.instance(); | ||
600 | } | ||
601 | } | ||
602 | |||
603 | private ContentInNotLive() { | ||
604 | super(GeneratedPQuery.INSTANCE); | ||
605 | } | ||
606 | |||
607 | /** | ||
608 | * @return the singleton instance of the query specification | ||
609 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
610 | * | ||
611 | */ | ||
612 | public static ContentInNotLive instance() { | ||
613 | try{ | ||
614 | return LazyHolder.INSTANCE; | ||
615 | } catch (ExceptionInInitializerError err) { | ||
616 | throw processInitializerError(err); | ||
617 | } | ||
618 | } | ||
619 | |||
620 | @Override | ||
621 | protected ContentInNotLive.Matcher instantiate(final ViatraQueryEngine engine) { | ||
622 | return ContentInNotLive.Matcher.on(engine); | ||
623 | } | ||
624 | |||
625 | @Override | ||
626 | public ContentInNotLive.Matcher instantiate() { | ||
627 | return ContentInNotLive.Matcher.create(); | ||
628 | } | ||
629 | |||
630 | @Override | ||
631 | public ContentInNotLive.Match newEmptyMatch() { | ||
632 | return ContentInNotLive.Match.newEmptyMatch(); | ||
633 | } | ||
634 | |||
635 | @Override | ||
636 | public ContentInNotLive.Match newMatch(final Object... parameters) { | ||
637 | return ContentInNotLive.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir) parameters[0], (hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject) parameters[1]); | ||
638 | } | ||
639 | |||
640 | /** | ||
641 | * Inner class allowing the singleton instance of {@link ContentInNotLive} to be created | ||
642 | * <b>not</b> at the class load time of the outer class, | ||
643 | * but rather at the first call to {@link ContentInNotLive#instance()}. | ||
644 | * | ||
645 | * <p> This workaround is required e.g. to support recursion. | ||
646 | * | ||
647 | */ | ||
648 | private static class LazyHolder { | ||
649 | private static final ContentInNotLive INSTANCE = new ContentInNotLive(); | ||
650 | |||
651 | /** | ||
652 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
653 | * This initialization order is required to support indirect recursion. | ||
654 | * | ||
655 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
656 | * | ||
657 | */ | ||
658 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
659 | |||
660 | public static Object ensureInitialized() { | ||
661 | INSTANCE.ensureInitializedInternal(); | ||
662 | return null; | ||
663 | } | ||
664 | } | ||
665 | |||
666 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
667 | private static final ContentInNotLive.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
668 | |||
669 | private final PParameter parameter_parent = new PParameter("parent", "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.Dir", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("FS", "Dir")), PParameterDirection.INOUT); | ||
670 | |||
671 | private final PParameter parameter_child = new PParameter("child", "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.Filesystem.FSObject", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("FS", "FSObject")), PParameterDirection.INOUT); | ||
672 | |||
673 | private final List<PParameter> parameters = Arrays.asList(parameter_parent, parameter_child); | ||
674 | |||
675 | private GeneratedPQuery() { | ||
676 | super(PVisibility.PUBLIC); | ||
677 | } | ||
678 | |||
679 | @Override | ||
680 | public String getFullyQualifiedName() { | ||
681 | return "hu.bme.mit.inf.dslreasoner.domains.alloyexamples.contentInNotLive"; | ||
682 | } | ||
683 | |||
684 | @Override | ||
685 | public List<String> getParameterNames() { | ||
686 | return Arrays.asList("parent","child"); | ||
687 | } | ||
688 | |||
689 | @Override | ||
690 | public List<PParameter> getParameters() { | ||
691 | return parameters; | ||
692 | } | ||
693 | |||
694 | @Override | ||
695 | public Set<PBody> doGetContainedBodies() { | ||
696 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
697 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
698 | { | ||
699 | PBody body = new PBody(this); | ||
700 | PVariable var_parent = body.getOrCreateVariableByName("parent"); | ||
701 | PVariable var_child = body.getOrCreateVariableByName("child"); | ||
702 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
703 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
704 | new TypeConstraint(body, Tuples.flatTupleOf(var_child), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
705 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
706 | new ExportedParameter(body, var_parent, parameter_parent), | ||
707 | new ExportedParameter(body, var_child, parameter_child) | ||
708 | )); | ||
709 | // Dir.contents(parent,child) | ||
710 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
711 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
712 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("FS", "Dir", "contents"))); | ||
713 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
714 | new Equality(body, var__virtual_0_, var_child); | ||
715 | // neg find live(_,parent) | ||
716 | new NegativePatternCall(body, Tuples.flatTupleOf(var___0_, var_parent), Live.instance().getInternalQueryRepresentation()); | ||
717 | bodies.add(body); | ||
718 | } | ||
719 | { | ||
720 | PBody body = new PBody(this); | ||
721 | PVariable var_parent = body.getOrCreateVariableByName("parent"); | ||
722 | PVariable var_child = body.getOrCreateVariableByName("child"); | ||
723 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
724 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
725 | new TypeConstraint(body, Tuples.flatTupleOf(var_child), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
726 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
727 | new ExportedParameter(body, var_parent, parameter_parent), | ||
728 | new ExportedParameter(body, var_child, parameter_child) | ||
729 | )); | ||
730 | // Dir.contents(parent,child) | ||
731 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "Dir"))); | ||
732 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
733 | new TypeConstraint(body, Tuples.flatTupleOf(var_parent, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("FS", "Dir", "contents"))); | ||
734 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("FS", "FSObject"))); | ||
735 | new Equality(body, var__virtual_0_, var_child); | ||
736 | // neg find live(_,child) | ||
737 | new NegativePatternCall(body, Tuples.flatTupleOf(var___0_, var_child), Live.instance().getInternalQueryRepresentation()); | ||
738 | bodies.add(body); | ||
739 | } | ||
740 | { | ||
741 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
742 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
743 | new ParameterReference("child") | ||
744 | })); | ||
745 | annotation.addAttribute("severity", "error"); | ||
746 | annotation.addAttribute("message", "error"); | ||
747 | addAnnotation(annotation); | ||
748 | } | ||
749 | return bodies; | ||
750 | } | ||
751 | } | ||
752 | } | ||