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