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