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