diff options
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv06.java')
-rw-r--r-- | Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv06.java | 509 |
1 files changed, 509 insertions, 0 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv06.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv06.java new file mode 100644 index 00000000..fcf7ac89 --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv06.java | |||
@@ -0,0 +1,509 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/case.study.a.queries/src/queries/case_study_A.vql | ||
3 | */ | ||
4 | package queries; | ||
5 | |||
6 | import Taxation.Tax_Payer; | ||
7 | import java.util.Arrays; | ||
8 | import java.util.Collection; | ||
9 | import java.util.LinkedHashSet; | ||
10 | import java.util.List; | ||
11 | import java.util.Optional; | ||
12 | import java.util.Set; | ||
13 | import java.util.function.Consumer; | ||
14 | import java.util.stream.Collectors; | ||
15 | import java.util.stream.Stream; | ||
16 | import org.apache.log4j.Logger; | ||
17 | import org.eclipse.emf.ecore.EClass; | ||
18 | import org.eclipse.emf.ecore.EDataType; | ||
19 | import org.eclipse.viatra.query.runtime.api.IQuerySpecification; | ||
20 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine; | ||
21 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery; | ||
22 | import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification; | ||
23 | import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher; | ||
24 | import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch; | ||
25 | import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey; | ||
26 | import org.eclipse.viatra.query.runtime.emf.types.EDataTypeInSlotsKey; | ||
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.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 | * //inv6-Does not make sens, but directly from OCL | ||
52 | * //first part of or from definition of getAge() | ||
53 | * {@literal @}Constraint(message = "inv06", severity = "error", key = {tp}) | ||
54 | * pattern inv06(tp : Tax_Payer) { | ||
55 | * Tax_Payer.dependents(tp, _); | ||
56 | * Tax_Payer.birth_year(tp, TPBy); | ||
57 | * check(2018 - TPBy {@literal >} 2018-16); | ||
58 | * } or { | ||
59 | * Tax_Payer.birth_year(tp, TPBy); | ||
60 | * Tax_Payer.dependents(tp, dep); | ||
61 | * Dependent.birth_year(dep, DepBy); | ||
62 | * check(2018-DepBy {@literal <}= 2018-TPBy-16); | ||
63 | * } | ||
64 | * </pre></code> | ||
65 | * | ||
66 | * @see Matcher | ||
67 | * @see Match | ||
68 | * | ||
69 | */ | ||
70 | @SuppressWarnings("all") | ||
71 | public final class Inv06 extends BaseGeneratedEMFQuerySpecification<Inv06.Matcher> { | ||
72 | /** | ||
73 | * Pattern-specific match representation of the queries.inv06 pattern, | ||
74 | * to be used in conjunction with {@link Matcher}. | ||
75 | * | ||
76 | * <p>Class fields correspond to parameters of the pattern. Fields with value null are considered unassigned. | ||
77 | * Each instance is a (possibly partial) substitution of pattern parameters, | ||
78 | * usable to represent a match of the pattern in the result of a query, | ||
79 | * or to specify the bound (fixed) input parameters when issuing a query. | ||
80 | * | ||
81 | * @see Matcher | ||
82 | * | ||
83 | */ | ||
84 | public static abstract class Match extends BasePatternMatch { | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * Generated pattern matcher API of the queries.inv06 pattern, | ||
89 | * providing pattern-specific query methods. | ||
90 | * | ||
91 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
92 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
93 | * | ||
94 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
95 | * | ||
96 | * <p>Original source: | ||
97 | * <code><pre> | ||
98 | * //inv6-Does not make sens, but directly from OCL | ||
99 | * //first part of or from definition of getAge() | ||
100 | * {@literal @}Constraint(message = "inv06", severity = "error", key = {tp}) | ||
101 | * pattern inv06(tp : Tax_Payer) { | ||
102 | * Tax_Payer.dependents(tp, _); | ||
103 | * Tax_Payer.birth_year(tp, TPBy); | ||
104 | * check(2018 - TPBy {@literal >} 2018-16); | ||
105 | * } or { | ||
106 | * Tax_Payer.birth_year(tp, TPBy); | ||
107 | * Tax_Payer.dependents(tp, dep); | ||
108 | * Dependent.birth_year(dep, DepBy); | ||
109 | * check(2018-DepBy {@literal <}= 2018-TPBy-16); | ||
110 | * } | ||
111 | * </pre></code> | ||
112 | * | ||
113 | * @see Match | ||
114 | * @see Inv06 | ||
115 | * | ||
116 | */ | ||
117 | public static class Matcher extends BaseMatcher<Inv06.Match> { | ||
118 | /** | ||
119 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
120 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
121 | * | ||
122 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
123 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
124 | * | ||
125 | */ | ||
126 | public static Inv06.Matcher on(final ViatraQueryEngine engine) { | ||
127 | // check if matcher already exists | ||
128 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
129 | if (matcher == null) { | ||
130 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
131 | } | ||
132 | return matcher; | ||
133 | } | ||
134 | |||
135 | /** | ||
136 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
137 | * @return an initialized matcher | ||
138 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
139 | * | ||
140 | */ | ||
141 | public static Inv06.Matcher create() { | ||
142 | return new Matcher(); | ||
143 | } | ||
144 | |||
145 | private static final int POSITION_TP = 0; | ||
146 | |||
147 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Inv06.Matcher.class); | ||
148 | |||
149 | /** | ||
150 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
151 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
152 | * | ||
153 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
154 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
155 | * | ||
156 | */ | ||
157 | private Matcher() { | ||
158 | super(querySpecification()); | ||
159 | } | ||
160 | |||
161 | /** | ||
162 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
163 | * @param pTp the fixed value of pattern parameter tp, or null if not bound. | ||
164 | * @return matches represented as a Match object. | ||
165 | * | ||
166 | */ | ||
167 | public Collection<Inv06.Match> getAllMatches(final Tax_Payer pTp) { | ||
168 | return rawStreamAllMatches(new Object[]{pTp}).collect(Collectors.toSet()); | ||
169 | } | ||
170 | |||
171 | /** | ||
172 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
173 | * </p> | ||
174 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
175 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
176 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
177 | * @param pTp the fixed value of pattern parameter tp, or null if not bound. | ||
178 | * @return a stream of matches represented as a Match object. | ||
179 | * | ||
180 | */ | ||
181 | public Stream<Inv06.Match> streamAllMatches(final Tax_Payer pTp) { | ||
182 | return rawStreamAllMatches(new Object[]{pTp}); | ||
183 | } | ||
184 | |||
185 | /** | ||
186 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
187 | * Neither determinism nor randomness of selection is guaranteed. | ||
188 | * @param pTp the fixed value of pattern parameter tp, or null if not bound. | ||
189 | * @return a match represented as a Match object, or null if no match is found. | ||
190 | * | ||
191 | */ | ||
192 | public Optional<Inv06.Match> getOneArbitraryMatch(); | ||
193 | |||
194 | /** | ||
195 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
196 | * under any possible substitution of the unspecified parameters (if any). | ||
197 | * @param pTp the fixed value of pattern parameter tp, or null if not bound. | ||
198 | * @return true if the input is a valid (partial) match of the pattern. | ||
199 | * | ||
200 | */ | ||
201 | public boolean hasMatch(final Tax_Payer pTp) { | ||
202 | return rawHasMatch(new Object[]{pTp}); | ||
203 | } | ||
204 | |||
205 | /** | ||
206 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
207 | * @param pTp the fixed value of pattern parameter tp, or null if not bound. | ||
208 | * @return the number of pattern matches found. | ||
209 | * | ||
210 | */ | ||
211 | public int countMatches(final Tax_Payer pTp) { | ||
212 | return rawCountMatches(new Object[]{pTp}); | ||
213 | } | ||
214 | |||
215 | /** | ||
216 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
217 | * Neither determinism nor randomness of selection is guaranteed. | ||
218 | * @param pTp the fixed value of pattern parameter tp, or null if not bound. | ||
219 | * @param processor the action that will process the selected match. | ||
220 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
221 | * | ||
222 | */ | ||
223 | public boolean forOneArbitraryMatch(final Tax_Payer pTp, final Consumer<? super Inv06.Match> processor) { | ||
224 | return rawForOneArbitraryMatch(new Object[]{pTp}, processor); | ||
225 | } | ||
226 | |||
227 | /** | ||
228 | * Returns a new (partial) match. | ||
229 | * This can be used e.g. to call the matcher with a partial match. | ||
230 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
231 | * @param pTp the fixed value of pattern parameter tp, or null if not bound. | ||
232 | * @return the (partial) match object. | ||
233 | * | ||
234 | */ | ||
235 | public Inv06.Match newMatch(final Tax_Payer pTp) { | ||
236 | return Inv06.Match.newMatch(pTp); | ||
237 | } | ||
238 | |||
239 | /** | ||
240 | * Retrieve the set of values that occur in matches for tp. | ||
241 | * @return the Set of all values or empty set if there are no matches | ||
242 | * | ||
243 | */ | ||
244 | protected Stream<Tax_Payer> rawStreamAllValuesOftp(final Object[] parameters) { | ||
245 | return rawStreamAllValues(POSITION_TP, parameters).map(Tax_Payer.class::cast); | ||
246 | } | ||
247 | |||
248 | /** | ||
249 | * Retrieve the set of values that occur in matches for tp. | ||
250 | * @return the Set of all values or empty set if there are no matches | ||
251 | * | ||
252 | */ | ||
253 | public Set<Tax_Payer> getAllValuesOftp() { | ||
254 | return rawStreamAllValuesOftp(emptyArray()).collect(Collectors.toSet()); | ||
255 | } | ||
256 | |||
257 | /** | ||
258 | * Retrieve the set of values that occur in matches for tp. | ||
259 | * @return the Set of all values or empty set if there are no matches | ||
260 | * | ||
261 | */ | ||
262 | public Stream<Tax_Payer> streamAllValuesOftp() { | ||
263 | return rawStreamAllValuesOftp(emptyArray()); | ||
264 | } | ||
265 | |||
266 | @Override | ||
267 | protected Inv06.Match tupleToMatch(final Tuple t) { | ||
268 | try { | ||
269 | return Inv06.Match.newMatch((Tax_Payer) t.get(POSITION_TP)); | ||
270 | } catch(ClassCastException e) { | ||
271 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
272 | return null; | ||
273 | } | ||
274 | } | ||
275 | |||
276 | @Override | ||
277 | protected Inv06.Match arrayToMatch(final Object[] match) { | ||
278 | try { | ||
279 | return Inv06.Match.newMatch((Tax_Payer) match[POSITION_TP]); | ||
280 | } catch(ClassCastException e) { | ||
281 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
282 | return null; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | @Override | ||
287 | protected Inv06.Match arrayToMatchMutable(final Object[] match) { | ||
288 | try { | ||
289 | return Inv06.Match.newMutableMatch((Tax_Payer) match[POSITION_TP]); | ||
290 | } catch(ClassCastException e) { | ||
291 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
292 | return null; | ||
293 | } | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * @return the singleton instance of the query specification of this pattern | ||
298 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
299 | * | ||
300 | */ | ||
301 | public static IQuerySpecification<Inv06.Matcher> querySpecification() { | ||
302 | return Inv06.instance(); | ||
303 | } | ||
304 | } | ||
305 | |||
306 | private Inv06() { | ||
307 | super(GeneratedPQuery.INSTANCE); | ||
308 | } | ||
309 | |||
310 | /** | ||
311 | * @return the singleton instance of the query specification | ||
312 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
313 | * | ||
314 | */ | ||
315 | public static Inv06 instance() { | ||
316 | try{ | ||
317 | return LazyHolder.INSTANCE; | ||
318 | } catch (ExceptionInInitializerError err) { | ||
319 | throw processInitializerError(err); | ||
320 | } | ||
321 | } | ||
322 | |||
323 | @Override | ||
324 | protected Inv06.Matcher instantiate(final ViatraQueryEngine engine) { | ||
325 | return Inv06.Matcher.on(engine); | ||
326 | } | ||
327 | |||
328 | @Override | ||
329 | public Inv06.Matcher instantiate() { | ||
330 | return Inv06.Matcher.create(); | ||
331 | } | ||
332 | |||
333 | @Override | ||
334 | public Inv06.Match newEmptyMatch() { | ||
335 | return Inv06.Match.newEmptyMatch(); | ||
336 | } | ||
337 | |||
338 | @Override | ||
339 | public Inv06.Match newMatch(final Object... parameters) { | ||
340 | return Inv06.Match.newMatch((Taxation.Tax_Payer) parameters[0]); | ||
341 | } | ||
342 | |||
343 | /** | ||
344 | * Inner class allowing the singleton instance of {@link Inv06} to be created | ||
345 | * <b>not</b> at the class load time of the outer class, | ||
346 | * but rather at the first call to {@link Inv06#instance()}. | ||
347 | * | ||
348 | * <p> This workaround is required e.g. to support recursion. | ||
349 | * | ||
350 | */ | ||
351 | private static class LazyHolder { | ||
352 | private static final Inv06 INSTANCE = new Inv06(); | ||
353 | |||
354 | /** | ||
355 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
356 | * This initialization order is required to support indirect recursion. | ||
357 | * | ||
358 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
359 | * | ||
360 | */ | ||
361 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
362 | |||
363 | public static Object ensureInitialized() { | ||
364 | INSTANCE.ensureInitializedInternal(); | ||
365 | return null; | ||
366 | } | ||
367 | } | ||
368 | |||
369 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
370 | private static final Inv06.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
371 | |||
372 | private final PParameter parameter_tp = new PParameter("tp", "Taxation.Tax_Payer", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http:///TaxCard.ecore", "Tax_Payer")), PParameterDirection.INOUT); | ||
373 | |||
374 | private final List<PParameter> parameters = Arrays.asList(parameter_tp); | ||
375 | |||
376 | private GeneratedPQuery() { | ||
377 | super(PVisibility.PUBLIC); | ||
378 | } | ||
379 | |||
380 | @Override | ||
381 | public String getFullyQualifiedName() { | ||
382 | return "queries.inv06"; | ||
383 | } | ||
384 | |||
385 | @Override | ||
386 | public List<String> getParameterNames() { | ||
387 | return Arrays.asList("tp"); | ||
388 | } | ||
389 | |||
390 | @Override | ||
391 | public List<PParameter> getParameters() { | ||
392 | return parameters; | ||
393 | } | ||
394 | |||
395 | @Override | ||
396 | public Set<PBody> doGetContainedBodies() { | ||
397 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
398 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
399 | { | ||
400 | PBody body = new PBody(this); | ||
401 | PVariable var_tp = body.getOrCreateVariableByName("tp"); | ||
402 | PVariable var___0_ = body.getOrCreateVariableByName("_<0>"); | ||
403 | PVariable var_TPBy = body.getOrCreateVariableByName("TPBy"); | ||
404 | new TypeConstraint(body, Tuples.flatTupleOf(var_tp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Tax_Payer"))); | ||
405 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
406 | new ExportedParameter(body, var_tp, parameter_tp) | ||
407 | )); | ||
408 | // Tax_Payer.dependents(tp, _) | ||
409 | new TypeConstraint(body, Tuples.flatTupleOf(var_tp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Tax_Payer"))); | ||
410 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
411 | new TypeConstraint(body, Tuples.flatTupleOf(var_tp, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Tax_Payer", "dependents"))); | ||
412 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Dependent"))); | ||
413 | new Equality(body, var__virtual_0_, var___0_); | ||
414 | // Tax_Payer.birth_year(tp, TPBy) | ||
415 | new TypeConstraint(body, Tuples.flatTupleOf(var_tp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Tax_Payer"))); | ||
416 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
417 | new TypeConstraint(body, Tuples.flatTupleOf(var_tp, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Physical_Person", "birth_year"))); | ||
418 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
419 | new Equality(body, var__virtual_1_, var_TPBy); | ||
420 | // check(2018 - TPBy > 2018-16) | ||
421 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
422 | |||
423 | @Override | ||
424 | public String getShortDescription() { | ||
425 | return "Expression evaluation from pattern inv06"; | ||
426 | } | ||
427 | |||
428 | @Override | ||
429 | public Iterable<String> getInputParameterNames() { | ||
430 | return Arrays.asList("TPBy");} | ||
431 | |||
432 | @Override | ||
433 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
434 | Integer TPBy = (Integer) provider.getValue("TPBy"); | ||
435 | return evaluateExpression_1_1(TPBy); | ||
436 | } | ||
437 | }, null); | ||
438 | bodies.add(body); | ||
439 | } | ||
440 | { | ||
441 | PBody body = new PBody(this); | ||
442 | PVariable var_tp = body.getOrCreateVariableByName("tp"); | ||
443 | PVariable var_TPBy = body.getOrCreateVariableByName("TPBy"); | ||
444 | PVariable var_dep = body.getOrCreateVariableByName("dep"); | ||
445 | PVariable var_DepBy = body.getOrCreateVariableByName("DepBy"); | ||
446 | new TypeConstraint(body, Tuples.flatTupleOf(var_tp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Tax_Payer"))); | ||
447 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
448 | new ExportedParameter(body, var_tp, parameter_tp) | ||
449 | )); | ||
450 | // Tax_Payer.birth_year(tp, TPBy) | ||
451 | new TypeConstraint(body, Tuples.flatTupleOf(var_tp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Tax_Payer"))); | ||
452 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
453 | new TypeConstraint(body, Tuples.flatTupleOf(var_tp, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Physical_Person", "birth_year"))); | ||
454 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
455 | new Equality(body, var__virtual_0_, var_TPBy); | ||
456 | // Tax_Payer.dependents(tp, dep) | ||
457 | new TypeConstraint(body, Tuples.flatTupleOf(var_tp), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Tax_Payer"))); | ||
458 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
459 | new TypeConstraint(body, Tuples.flatTupleOf(var_tp, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Tax_Payer", "dependents"))); | ||
460 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Dependent"))); | ||
461 | new Equality(body, var__virtual_1_, var_dep); | ||
462 | // Dependent.birth_year(dep, DepBy) | ||
463 | new TypeConstraint(body, Tuples.flatTupleOf(var_dep), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Dependent"))); | ||
464 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
465 | new TypeConstraint(body, Tuples.flatTupleOf(var_dep, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Physical_Person", "birth_year"))); | ||
466 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EInt"))); | ||
467 | new Equality(body, var__virtual_2_, var_DepBy); | ||
468 | // check(2018-DepBy <= 2018-TPBy-16) | ||
469 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
470 | |||
471 | @Override | ||
472 | public String getShortDescription() { | ||
473 | return "Expression evaluation from pattern inv06"; | ||
474 | } | ||
475 | |||
476 | @Override | ||
477 | public Iterable<String> getInputParameterNames() { | ||
478 | return Arrays.asList("DepBy", "TPBy");} | ||
479 | |||
480 | @Override | ||
481 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
482 | Integer DepBy = (Integer) provider.getValue("DepBy"); | ||
483 | Integer TPBy = (Integer) provider.getValue("TPBy"); | ||
484 | return evaluateExpression_2_1(DepBy, TPBy); | ||
485 | } | ||
486 | }, null); | ||
487 | bodies.add(body); | ||
488 | } | ||
489 | { | ||
490 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
491 | annotation.addAttribute("message", "inv06"); | ||
492 | annotation.addAttribute("severity", "error"); | ||
493 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
494 | new ParameterReference("tp") | ||
495 | })); | ||
496 | addAnnotation(annotation); | ||
497 | } | ||
498 | return bodies; | ||
499 | } | ||
500 | } | ||
501 | |||
502 | private static boolean evaluateExpression_1_1(final Integer TPBy) { | ||
503 | return ((2018 - (TPBy).intValue()) > (2018 - 16)); | ||
504 | } | ||
505 | |||
506 | private static boolean evaluateExpression_2_1(final Integer DepBy, final Integer TPBy) { | ||
507 | return ((2018 - (DepBy).intValue()) <= ((2018 - (TPBy).intValue()) - 16)); | ||
508 | } | ||
509 | } | ||