diff options
author | ArenBabikian <aren.babikian@mail.mcgill.ca> | 2020-04-26 18:23:13 -0400 |
---|---|---|
committer | ArenBabikian <aren.babikian@mail.mcgill.ca> | 2020-04-26 18:23:13 -0400 |
commit | c0a758eedd457a5d8eb9f1a6c17fc24143aabb3e (patch) | |
tree | 0c2e212e4e95c1d2311629128641d5cd561210f3 /Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv07.java | |
parent | Merge branch 'Attribute-Solver' (diff) | |
download | VIATRA-Generator-c0a758eedd457a5d8eb9f1a6c17fc24143aabb3e.tar.gz VIATRA-Generator-c0a758eedd457a5d8eb9f1a6c17fc24143aabb3e.tar.zst VIATRA-Generator-c0a758eedd457a5d8eb9f1a6c17fc24143aabb3e.zip |
Add PLEDGE case study files
Diffstat (limited to 'Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv07.java')
-rw-r--r-- | Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv07.java | 455 |
1 files changed, 455 insertions, 0 deletions
diff --git a/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv07.java b/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv07.java new file mode 100644 index 00000000..d9fed653 --- /dev/null +++ b/Tests/MODELS2020-CaseStudies/case.study.pledge.queries/src-gen/queries/Inv07.java | |||
@@ -0,0 +1,455 @@ | |||
1 | /** | ||
2 | * Generated from platform:/resource/case.study.a.queries/src/queries/case_study_A.vql | ||
3 | */ | ||
4 | package queries; | ||
5 | |||
6 | import Taxation.Income; | ||
7 | import com.google.common.base.Objects; | ||
8 | import java.util.Arrays; | ||
9 | import java.util.Collection; | ||
10 | import java.util.LinkedHashSet; | ||
11 | import java.util.List; | ||
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.emf.ecore.EDataType; | ||
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.EDataTypeInSlotsKey; | ||
28 | import org.eclipse.viatra.query.runtime.emf.types.EStructuralFeatureInstancesKey; | ||
29 | import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint; | ||
30 | import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator; | ||
31 | import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider; | ||
32 | import org.eclipse.viatra.query.runtime.matchers.psystem.PBody; | ||
33 | import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable; | ||
34 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation; | ||
35 | import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference; | ||
36 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.Equality; | ||
37 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter; | ||
38 | import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation; | ||
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 | * //inv7-OrderedSet | ||
53 | * {@literal @}Constraint(message = "inv07", severity = "error", key = {inc}) | ||
54 | * pattern inv07(inc : Income) { | ||
55 | * Income.details.distance(inc, d1); | ||
56 | * Income.details.distance(inc, d2); | ||
57 | * check(d1 != d2);//compare values | ||
58 | * } | ||
59 | * </pre></code> | ||
60 | * | ||
61 | * @see Matcher | ||
62 | * @see Match | ||
63 | * | ||
64 | */ | ||
65 | @SuppressWarnings("all") | ||
66 | public final class Inv07 extends BaseGeneratedEMFQuerySpecification<Inv07.Matcher> { | ||
67 | /** | ||
68 | * Pattern-specific match representation of the queries.inv07 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 | } | ||
81 | |||
82 | /** | ||
83 | * Generated pattern matcher API of the queries.inv07 pattern, | ||
84 | * providing pattern-specific query methods. | ||
85 | * | ||
86 | * <p>Use the pattern matcher on a given model via {@link #on(ViatraQueryEngine)}, | ||
87 | * e.g. in conjunction with {@link ViatraQueryEngine#on(QueryScope)}. | ||
88 | * | ||
89 | * <p>Matches of the pattern will be represented as {@link Match}. | ||
90 | * | ||
91 | * <p>Original source: | ||
92 | * <code><pre> | ||
93 | * //inv7-OrderedSet | ||
94 | * {@literal @}Constraint(message = "inv07", severity = "error", key = {inc}) | ||
95 | * pattern inv07(inc : Income) { | ||
96 | * Income.details.distance(inc, d1); | ||
97 | * Income.details.distance(inc, d2); | ||
98 | * check(d1 != d2);//compare values | ||
99 | * } | ||
100 | * </pre></code> | ||
101 | * | ||
102 | * @see Match | ||
103 | * @see Inv07 | ||
104 | * | ||
105 | */ | ||
106 | public static class Matcher extends BaseMatcher<Inv07.Match> { | ||
107 | /** | ||
108 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
109 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
110 | * | ||
111 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
112 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
113 | * | ||
114 | */ | ||
115 | public static Inv07.Matcher on(final ViatraQueryEngine engine) { | ||
116 | // check if matcher already exists | ||
117 | Matcher matcher = engine.getExistingMatcher(querySpecification()); | ||
118 | if (matcher == null) { | ||
119 | matcher = (Matcher)engine.getMatcher(querySpecification()); | ||
120 | } | ||
121 | return matcher; | ||
122 | } | ||
123 | |||
124 | /** | ||
125 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
126 | * @return an initialized matcher | ||
127 | * @noreference This method is for internal matcher initialization by the framework, do not call it manually. | ||
128 | * | ||
129 | */ | ||
130 | public static Inv07.Matcher create() { | ||
131 | return new Matcher(); | ||
132 | } | ||
133 | |||
134 | private static final int POSITION_INC = 0; | ||
135 | |||
136 | private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(Inv07.Matcher.class); | ||
137 | |||
138 | /** | ||
139 | * Initializes the pattern matcher within an existing VIATRA Query engine. | ||
140 | * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned. | ||
141 | * | ||
142 | * @param engine the existing VIATRA Query engine in which this matcher will be created. | ||
143 | * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation | ||
144 | * | ||
145 | */ | ||
146 | private Matcher() { | ||
147 | super(querySpecification()); | ||
148 | } | ||
149 | |||
150 | /** | ||
151 | * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters. | ||
152 | * @param pInc the fixed value of pattern parameter inc, or null if not bound. | ||
153 | * @return matches represented as a Match object. | ||
154 | * | ||
155 | */ | ||
156 | public Collection<Inv07.Match> getAllMatches(final Income pInc) { | ||
157 | return rawStreamAllMatches(new Object[]{pInc}).collect(Collectors.toSet()); | ||
158 | } | ||
159 | |||
160 | /** | ||
161 | * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters. | ||
162 | * </p> | ||
163 | * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed. | ||
164 | * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>. | ||
165 | * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code. | ||
166 | * @param pInc the fixed value of pattern parameter inc, or null if not bound. | ||
167 | * @return a stream of matches represented as a Match object. | ||
168 | * | ||
169 | */ | ||
170 | public Stream<Inv07.Match> streamAllMatches(final Income pInc) { | ||
171 | return rawStreamAllMatches(new Object[]{pInc}); | ||
172 | } | ||
173 | |||
174 | /** | ||
175 | * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
176 | * Neither determinism nor randomness of selection is guaranteed. | ||
177 | * @param pInc the fixed value of pattern parameter inc, or null if not bound. | ||
178 | * @return a match represented as a Match object, or null if no match is found. | ||
179 | * | ||
180 | */ | ||
181 | public Optional<Inv07.Match> getOneArbitraryMatch(final Income pInc) { | ||
182 | return rawGetOneArbitraryMatch(new Object[]{pInc}); | ||
183 | } | ||
184 | |||
185 | /** | ||
186 | * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match, | ||
187 | * under any possible substitution of the unspecified parameters (if any). | ||
188 | * @param pInc the fixed value of pattern parameter inc, or null if not bound. | ||
189 | * @return true if the input is a valid (partial) match of the pattern. | ||
190 | * | ||
191 | */ | ||
192 | public boolean hasMatch(final Income pInc) { | ||
193 | return rawHasMatch(new Object[]{pInc}); | ||
194 | } | ||
195 | |||
196 | /** | ||
197 | * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters. | ||
198 | * @param pInc the fixed value of pattern parameter inc, or null if not bound. | ||
199 | * @return the number of pattern matches found. | ||
200 | * | ||
201 | */ | ||
202 | public int countMatches(final Income pInc) { | ||
203 | return rawCountMatches(new Object[]{pInc}); | ||
204 | } | ||
205 | |||
206 | /** | ||
207 | * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters. | ||
208 | * Neither determinism nor randomness of selection is guaranteed. | ||
209 | * @param pInc the fixed value of pattern parameter inc, or null if not bound. | ||
210 | * @param processor the action that will process the selected match. | ||
211 | * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked | ||
212 | * | ||
213 | */ | ||
214 | public boolean forOneArbitraryMatch(final Income pInc, final Consumer<? super Inv07.Match> processor) { | ||
215 | return rawForOneArbitraryMatch(new Object[]{pInc}, processor); | ||
216 | } | ||
217 | |||
218 | /** | ||
219 | * Returns a new (partial) match. | ||
220 | * This can be used e.g. to call the matcher with a partial match. | ||
221 | * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object. | ||
222 | * @param pInc the fixed value of pattern parameter inc, or null if not bound. | ||
223 | * @return the (partial) match object. | ||
224 | * | ||
225 | */ | ||
226 | public Inv07.Match newMatch(final Income pInc) { | ||
227 | return Inv07.Match.newMatch(pInc); | ||
228 | } | ||
229 | |||
230 | /** | ||
231 | * Retrieve the set of values that occur in matches for inc. | ||
232 | * @return the Set of all values or empty set if there are no matches | ||
233 | * | ||
234 | */ | ||
235 | protected Stream<Income> rawStreamAllValuesOfinc(final Object[] parameters) { | ||
236 | return rawStreamAllValues(POSITION_INC, parameters).map(Income.class::cast); | ||
237 | } | ||
238 | |||
239 | /** | ||
240 | * Retrieve the set of values that occur in matches for inc. | ||
241 | * @return the Set of all values or empty set if there are no matches | ||
242 | * | ||
243 | */ | ||
244 | public Set<Income> getAllValuesOfinc() { | ||
245 | return rawStreamAllValuesOfinc(emptyArray()).collect(Collectors.toSet()); | ||
246 | } | ||
247 | |||
248 | /** | ||
249 | * Retrieve the set of values that occur in matches for inc. | ||
250 | * @return the Set of all values or empty set if there are no matches | ||
251 | * | ||
252 | */ | ||
253 | public Stream<Income> streamAllValuesOfinc() { | ||
254 | return rawStreamAllValuesOfinc(emptyArray()); | ||
255 | } | ||
256 | |||
257 | @Override | ||
258 | protected Inv07.Match tupleToMatch(final Tuple t) { | ||
259 | try { | ||
260 | return Inv07.Match.newMatch((Income) t.get(POSITION_INC)); | ||
261 | } catch(ClassCastException e) { | ||
262 | LOGGER.error("Element(s) in tuple not properly typed!",e); | ||
263 | return null; | ||
264 | } | ||
265 | } | ||
266 | |||
267 | @Override | ||
268 | protected Inv07.Match arrayToMatch(final Object[] match) { | ||
269 | try { | ||
270 | return Inv07.Match.newMatch((Income) match[POSITION_INC]); | ||
271 | } catch(ClassCastException e) { | ||
272 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
273 | return null; | ||
274 | } | ||
275 | } | ||
276 | |||
277 | @Override | ||
278 | protected Inv07.Match arrayToMatchMutable(final Object[] match) { | ||
279 | try { | ||
280 | return Inv07.Match.newMutableMatch((Income) match[POSITION_INC]); | ||
281 | } catch(ClassCastException e) { | ||
282 | LOGGER.error("Element(s) in array not properly typed!",e); | ||
283 | return null; | ||
284 | } | ||
285 | } | ||
286 | |||
287 | /** | ||
288 | * @return the singleton instance of the query specification of this pattern | ||
289 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
290 | * | ||
291 | */ | ||
292 | public static IQuerySpecification<Inv07.Matcher> querySpecification() { | ||
293 | return Inv07.instance(); | ||
294 | } | ||
295 | } | ||
296 | |||
297 | private Inv07() { | ||
298 | super(GeneratedPQuery.INSTANCE); | ||
299 | } | ||
300 | |||
301 | /** | ||
302 | * @return the singleton instance of the query specification | ||
303 | * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded | ||
304 | * | ||
305 | */ | ||
306 | public static Inv07 instance() { | ||
307 | try{ | ||
308 | return LazyHolder.INSTANCE; | ||
309 | } catch (ExceptionInInitializerError err) { | ||
310 | throw processInitializerError(err); | ||
311 | } | ||
312 | } | ||
313 | |||
314 | @Override | ||
315 | protected Inv07.Matcher instantiate(final ViatraQueryEngine engine) { | ||
316 | return Inv07.Matcher.on(engine); | ||
317 | } | ||
318 | |||
319 | @Override | ||
320 | public Inv07.Matcher instantiate() { | ||
321 | return Inv07.Matcher.create(); | ||
322 | } | ||
323 | |||
324 | @Override | ||
325 | public Inv07.Match newEmptyMatch() { | ||
326 | return Inv07.Match.newEmptyMatch(); | ||
327 | } | ||
328 | |||
329 | @Override | ||
330 | public Inv07.Match newMatch(final Object... parameters) { | ||
331 | return Inv07.Match.newMatch((Taxation.Income) parameters[0]); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * Inner class allowing the singleton instance of {@link Inv07} to be created | ||
336 | * <b>not</b> at the class load time of the outer class, | ||
337 | * but rather at the first call to {@link Inv07#instance()}. | ||
338 | * | ||
339 | * <p> This workaround is required e.g. to support recursion. | ||
340 | * | ||
341 | */ | ||
342 | private static class LazyHolder { | ||
343 | private static final Inv07 INSTANCE = new Inv07(); | ||
344 | |||
345 | /** | ||
346 | * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned. | ||
347 | * This initialization order is required to support indirect recursion. | ||
348 | * | ||
349 | * <p> The static initializer is defined using a helper field to work around limitations of the code generator. | ||
350 | * | ||
351 | */ | ||
352 | private static final Object STATIC_INITIALIZER = ensureInitialized(); | ||
353 | |||
354 | public static Object ensureInitialized() { | ||
355 | INSTANCE.ensureInitializedInternal(); | ||
356 | return null; | ||
357 | } | ||
358 | } | ||
359 | |||
360 | private static class GeneratedPQuery extends BaseGeneratedEMFPQuery { | ||
361 | private static final Inv07.GeneratedPQuery INSTANCE = new GeneratedPQuery(); | ||
362 | |||
363 | private final PParameter parameter_inc = new PParameter("inc", "Taxation.Income", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http:///TaxCard.ecore", "Income")), PParameterDirection.INOUT); | ||
364 | |||
365 | private final List<PParameter> parameters = Arrays.asList(parameter_inc); | ||
366 | |||
367 | private GeneratedPQuery() { | ||
368 | super(PVisibility.PUBLIC); | ||
369 | } | ||
370 | |||
371 | @Override | ||
372 | public String getFullyQualifiedName() { | ||
373 | return "queries.inv07"; | ||
374 | } | ||
375 | |||
376 | @Override | ||
377 | public List<String> getParameterNames() { | ||
378 | return Arrays.asList("inc"); | ||
379 | } | ||
380 | |||
381 | @Override | ||
382 | public List<PParameter> getParameters() { | ||
383 | return parameters; | ||
384 | } | ||
385 | |||
386 | @Override | ||
387 | public Set<PBody> doGetContainedBodies() { | ||
388 | setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED)); | ||
389 | Set<PBody> bodies = new LinkedHashSet<>(); | ||
390 | { | ||
391 | PBody body = new PBody(this); | ||
392 | PVariable var_inc = body.getOrCreateVariableByName("inc"); | ||
393 | PVariable var_d1 = body.getOrCreateVariableByName("d1"); | ||
394 | PVariable var_d2 = body.getOrCreateVariableByName("d2"); | ||
395 | new TypeConstraint(body, Tuples.flatTupleOf(var_inc), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Income"))); | ||
396 | body.setSymbolicParameters(Arrays.<ExportedParameter>asList( | ||
397 | new ExportedParameter(body, var_inc, parameter_inc) | ||
398 | )); | ||
399 | // Income.details.distance(inc, d1) | ||
400 | new TypeConstraint(body, Tuples.flatTupleOf(var_inc), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Income"))); | ||
401 | PVariable var__virtual_0_ = body.getOrCreateVariableByName(".virtual{0}"); | ||
402 | new TypeConstraint(body, Tuples.flatTupleOf(var_inc, var__virtual_0_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Income", "details"))); | ||
403 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Income_Detail"))); | ||
404 | PVariable var__virtual_1_ = body.getOrCreateVariableByName(".virtual{1}"); | ||
405 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_0_, var__virtual_1_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Income_Detail", "distance"))); | ||
406 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_1_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EDouble"))); | ||
407 | new Equality(body, var__virtual_1_, var_d1); | ||
408 | // Income.details.distance(inc, d2) | ||
409 | new TypeConstraint(body, Tuples.flatTupleOf(var_inc), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Income"))); | ||
410 | PVariable var__virtual_2_ = body.getOrCreateVariableByName(".virtual{2}"); | ||
411 | new TypeConstraint(body, Tuples.flatTupleOf(var_inc, var__virtual_2_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Income", "details"))); | ||
412 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http:///TaxCard.ecore", "Income_Detail"))); | ||
413 | PVariable var__virtual_3_ = body.getOrCreateVariableByName(".virtual{3}"); | ||
414 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_2_, var__virtual_3_), new EStructuralFeatureInstancesKey(getFeatureLiteral("http:///TaxCard.ecore", "Income_Detail", "distance"))); | ||
415 | new TypeConstraint(body, Tuples.flatTupleOf(var__virtual_3_), new EDataTypeInSlotsKey((EDataType)getClassifierLiteral("http://www.eclipse.org/emf/2002/Ecore", "EDouble"))); | ||
416 | new Equality(body, var__virtual_3_, var_d2); | ||
417 | // check(d1 != d2) | ||
418 | new ExpressionEvaluation(body, new IExpressionEvaluator() { | ||
419 | |||
420 | @Override | ||
421 | public String getShortDescription() { | ||
422 | return "Expression evaluation from pattern inv07"; | ||
423 | } | ||
424 | |||
425 | @Override | ||
426 | public Iterable<String> getInputParameterNames() { | ||
427 | return Arrays.asList("d1", "d2");} | ||
428 | |||
429 | @Override | ||
430 | public Object evaluateExpression(IValueProvider provider) throws Exception { | ||
431 | Double d1 = (Double) provider.getValue("d1"); | ||
432 | Double d2 = (Double) provider.getValue("d2"); | ||
433 | return evaluateExpression_1_1(d1, d2); | ||
434 | } | ||
435 | }, null); | ||
436 | bodies.add(body); | ||
437 | } | ||
438 | { | ||
439 | PAnnotation annotation = new PAnnotation("Constraint"); | ||
440 | annotation.addAttribute("message", "inv07"); | ||
441 | annotation.addAttribute("severity", "error"); | ||
442 | annotation.addAttribute("key", Arrays.asList(new Object[] { | ||
443 | new ParameterReference("inc") | ||
444 | })); | ||
445 | addAnnotation(annotation); | ||
446 | } | ||
447 | return bodies; | ||
448 | } | ||
449 | } | ||
450 | |||
451 | private static boolean evaluateExpression_1_1(final Double d1, final Double d2) { | ||
452 | boolean _notEquals = (!Objects.equal(d1, d2)); | ||
453 | return _notEquals; | ||
454 | } | ||
455 | } | ||