aboutsummaryrefslogtreecommitdiffstats
path: root/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kris7topher@gmail.com>2019-05-15 13:46:38 -0400
committerLibravatar Kristóf Marussy <kris7topher@gmail.com>2019-05-15 13:46:38 -0400
commite904f9d4b1d2d15ab4ec6d72ee881f4c7de34eef (patch)
tree42cb23ff8839308345c0859cdf99469c930af03b /Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java
parentMerge remote-tracking branch 'origin/master' into kris (diff)
downloadVIATRA-Generator-e904f9d4b1d2d15ab4ec6d72ee881f4c7de34eef.tar.gz
VIATRA-Generator-e904f9d4b1d2d15ab4ec6d72ee881f4c7de34eef.tar.zst
VIATRA-Generator-e904f9d4b1d2d15ab4ec6d72ee881f4c7de34eef.zip
Formalize CPS case study for optimization
Diffstat (limited to 'Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java')
-rw-r--r--Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java579
1 files changed, 579 insertions, 0 deletions
diff --git a/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java
new file mode 100644
index 00000000..4803ec3a
--- /dev/null
+++ b/Domains/hu.bme.mit.inf.dslreasoner.domains.cps/src-gen/hu/bme/mit/inf/dslreasoner/domains/cps/queries/NotEnoughAvailableMemory.java
@@ -0,0 +1,579 @@
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.HostInstance;
7import hu.bme.mit.inf.dslreasoner.domains.cps.queries.AvailableMemory;
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.viatra.query.runtime.api.IPatternMatch;
21import org.eclipse.viatra.query.runtime.api.IQuerySpecification;
22import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine;
23import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFPQuery;
24import org.eclipse.viatra.query.runtime.api.impl.BaseGeneratedEMFQuerySpecification;
25import org.eclipse.viatra.query.runtime.api.impl.BaseMatcher;
26import org.eclipse.viatra.query.runtime.api.impl.BasePatternMatch;
27import org.eclipse.viatra.query.runtime.emf.types.EClassTransitiveInstancesKey;
28import org.eclipse.viatra.query.runtime.matchers.backend.QueryEvaluationHint;
29import org.eclipse.viatra.query.runtime.matchers.psystem.IExpressionEvaluator;
30import org.eclipse.viatra.query.runtime.matchers.psystem.IValueProvider;
31import org.eclipse.viatra.query.runtime.matchers.psystem.PBody;
32import org.eclipse.viatra.query.runtime.matchers.psystem.PVariable;
33import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.PAnnotation;
34import org.eclipse.viatra.query.runtime.matchers.psystem.annotations.ParameterReference;
35import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExportedParameter;
36import org.eclipse.viatra.query.runtime.matchers.psystem.basicdeferred.ExpressionEvaluation;
37import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.PositivePatternCall;
38import org.eclipse.viatra.query.runtime.matchers.psystem.basicenumerables.TypeConstraint;
39import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameter;
40import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PParameterDirection;
41import org.eclipse.viatra.query.runtime.matchers.psystem.queries.PVisibility;
42import org.eclipse.viatra.query.runtime.matchers.tuple.Tuple;
43import org.eclipse.viatra.query.runtime.matchers.tuple.Tuples;
44import org.eclipse.viatra.query.runtime.util.ViatraQueryLoggingUtil;
45
46/**
47 * A pattern-specific query specification that can instantiate Matcher in a type-safe way.
48 *
49 * <p>Original source:
50 * <code><pre>
51 * {@literal @}Constraint(severity = "error", key = {Host},
52 * message = "Insufficient memory available on host.")
53 * pattern notEnoughAvailableMemory(Host : HostInstance) {
54 * find availableMemory(Host, Memory);
55 * check(Memory {@literal <} 0);
56 * }
57 * </pre></code>
58 *
59 * @see Matcher
60 * @see Match
61 *
62 */
63@SuppressWarnings("all")
64public final class NotEnoughAvailableMemory extends BaseGeneratedEMFQuerySpecification<NotEnoughAvailableMemory.Matcher> {
65 /**
66 * Pattern-specific match representation of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory 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 HostInstance fHost;
79
80 private static List<String> parameterNames = makeImmutableList("Host");
81
82 private Match(final HostInstance pHost) {
83 this.fHost = pHost;
84 }
85
86 @Override
87 public Object get(final String parameterName) {
88 if ("Host".equals(parameterName)) return this.fHost;
89 return null;
90 }
91
92 public HostInstance getHost() {
93 return this.fHost;
94 }
95
96 @Override
97 public boolean set(final String parameterName, final Object newValue) {
98 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
99 if ("Host".equals(parameterName) ) {
100 this.fHost = (HostInstance) newValue;
101 return true;
102 }
103 return false;
104 }
105
106 public void setHost(final HostInstance pHost) {
107 if (!isMutable()) throw new java.lang.UnsupportedOperationException();
108 this.fHost = pHost;
109 }
110
111 @Override
112 public String patternName() {
113 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory";
114 }
115
116 @Override
117 public List<String> parameterNames() {
118 return NotEnoughAvailableMemory.Match.parameterNames;
119 }
120
121 @Override
122 public Object[] toArray() {
123 return new Object[]{fHost};
124 }
125
126 @Override
127 public NotEnoughAvailableMemory.Match toImmutable() {
128 return isMutable() ? newMatch(fHost) : this;
129 }
130
131 @Override
132 public String prettyPrint() {
133 StringBuilder result = new StringBuilder();
134 result.append("\"Host\"=" + prettyPrintValue(fHost));
135 return result.toString();
136 }
137
138 @Override
139 public int hashCode() {
140 return Objects.hash(fHost);
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 NotEnoughAvailableMemory.Match)) {
151 NotEnoughAvailableMemory.Match other = (NotEnoughAvailableMemory.Match) obj;
152 return Objects.equals(fHost, other.fHost);
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 NotEnoughAvailableMemory specification() {
165 return NotEnoughAvailableMemory.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 NotEnoughAvailableMemory.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 pHost the fixed value of pattern parameter Host, or null if not bound.
184 * @return the new, mutable (partial) match object.
185 *
186 */
187 public static NotEnoughAvailableMemory.Match newMutableMatch(final HostInstance pHost) {
188 return new Mutable(pHost);
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 pHost the fixed value of pattern parameter Host, or null if not bound.
196 * @return the (partial) match object.
197 *
198 */
199 public static NotEnoughAvailableMemory.Match newMatch(final HostInstance pHost) {
200 return new Immutable(pHost);
201 }
202
203 private static final class Mutable extends NotEnoughAvailableMemory.Match {
204 Mutable(final HostInstance pHost) {
205 super(pHost);
206 }
207
208 @Override
209 public boolean isMutable() {
210 return true;
211 }
212 }
213
214 private static final class Immutable extends NotEnoughAvailableMemory.Match {
215 Immutable(final HostInstance pHost) {
216 super(pHost);
217 }
218
219 @Override
220 public boolean isMutable() {
221 return false;
222 }
223 }
224 }
225
226 /**
227 * Generated pattern matcher API of the hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory 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", key = {Host},
238 * message = "Insufficient memory available on host.")
239 * pattern notEnoughAvailableMemory(Host : HostInstance) {
240 * find availableMemory(Host, Memory);
241 * check(Memory {@literal <} 0);
242 * }
243 * </pre></code>
244 *
245 * @see Match
246 * @see NotEnoughAvailableMemory
247 *
248 */
249 public static class Matcher extends BaseMatcher<NotEnoughAvailableMemory.Match> {
250 /**
251 * Initializes the pattern matcher within an existing VIATRA Query engine.
252 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
253 *
254 * @param engine the existing VIATRA Query engine in which this matcher will be created.
255 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
256 *
257 */
258 public static NotEnoughAvailableMemory.Matcher on(final ViatraQueryEngine engine) {
259 // check if matcher already exists
260 Matcher matcher = engine.getExistingMatcher(querySpecification());
261 if (matcher == null) {
262 matcher = (Matcher)engine.getMatcher(querySpecification());
263 }
264 return matcher;
265 }
266
267 /**
268 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
269 * @return an initialized matcher
270 * @noreference This method is for internal matcher initialization by the framework, do not call it manually.
271 *
272 */
273 public static NotEnoughAvailableMemory.Matcher create() {
274 return new Matcher();
275 }
276
277 private static final int POSITION_HOST = 0;
278
279 private static final Logger LOGGER = ViatraQueryLoggingUtil.getLogger(NotEnoughAvailableMemory.Matcher.class);
280
281 /**
282 * Initializes the pattern matcher within an existing VIATRA Query engine.
283 * If the pattern matcher is already constructed in the engine, only a light-weight reference is returned.
284 *
285 * @param engine the existing VIATRA Query engine in which this matcher will be created.
286 * @throws ViatraQueryRuntimeException if an error occurs during pattern matcher creation
287 *
288 */
289 private Matcher() {
290 super(querySpecification());
291 }
292
293 /**
294 * Returns the set of all matches of the pattern that conform to the given fixed values of some parameters.
295 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
296 * @return matches represented as a Match object.
297 *
298 */
299 public Collection<NotEnoughAvailableMemory.Match> getAllMatches(final HostInstance pHost) {
300 return rawStreamAllMatches(new Object[]{pHost}).collect(Collectors.toSet());
301 }
302
303 /**
304 * Returns a stream of all matches of the pattern that conform to the given fixed values of some parameters.
305 * </p>
306 * <strong>NOTE</strong>: It is important not to modify the source model while the stream is being processed.
307 * If the match set of the pattern changes during processing, the contents of the stream is <strong>undefined</strong>.
308 * In such cases, either rely on {@link #getAllMatches()} or collect the results of the stream in end-user code.
309 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
310 * @return a stream of matches represented as a Match object.
311 *
312 */
313 public Stream<NotEnoughAvailableMemory.Match> streamAllMatches(final HostInstance pHost) {
314 return rawStreamAllMatches(new Object[]{pHost});
315 }
316
317 /**
318 * Returns an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
319 * Neither determinism nor randomness of selection is guaranteed.
320 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
321 * @return a match represented as a Match object, or null if no match is found.
322 *
323 */
324 public Optional<NotEnoughAvailableMemory.Match> getOneArbitraryMatch(final HostInstance pHost) {
325 return rawGetOneArbitraryMatch(new Object[]{pHost});
326 }
327
328 /**
329 * Indicates whether the given combination of specified pattern parameters constitute a valid pattern match,
330 * under any possible substitution of the unspecified parameters (if any).
331 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
332 * @return true if the input is a valid (partial) match of the pattern.
333 *
334 */
335 public boolean hasMatch(final HostInstance pHost) {
336 return rawHasMatch(new Object[]{pHost});
337 }
338
339 /**
340 * Returns the number of all matches of the pattern that conform to the given fixed values of some parameters.
341 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
342 * @return the number of pattern matches found.
343 *
344 */
345 public int countMatches(final HostInstance pHost) {
346 return rawCountMatches(new Object[]{pHost});
347 }
348
349 /**
350 * Executes the given processor on an arbitrarily chosen match of the pattern that conforms to the given fixed values of some parameters.
351 * Neither determinism nor randomness of selection is guaranteed.
352 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
353 * @param processor the action that will process the selected match.
354 * @return true if the pattern has at least one match with the given parameter values, false if the processor was not invoked
355 *
356 */
357 public boolean forOneArbitraryMatch(final HostInstance pHost, final Consumer<? super NotEnoughAvailableMemory.Match> processor) {
358 return rawForOneArbitraryMatch(new Object[]{pHost}, processor);
359 }
360
361 /**
362 * Returns a new (partial) match.
363 * This can be used e.g. to call the matcher with a partial match.
364 * <p>The returned match will be immutable. Use {@link #newEmptyMatch()} to obtain a mutable match object.
365 * @param pHost the fixed value of pattern parameter Host, or null if not bound.
366 * @return the (partial) match object.
367 *
368 */
369 public NotEnoughAvailableMemory.Match newMatch(final HostInstance pHost) {
370 return NotEnoughAvailableMemory.Match.newMatch(pHost);
371 }
372
373 /**
374 * Retrieve the set of values that occur in matches for Host.
375 * @return the Set of all values or empty set if there are no matches
376 *
377 */
378 protected Stream<HostInstance> rawStreamAllValuesOfHost(final Object[] parameters) {
379 return rawStreamAllValues(POSITION_HOST, parameters).map(HostInstance.class::cast);
380 }
381
382 /**
383 * Retrieve the set of values that occur in matches for Host.
384 * @return the Set of all values or empty set if there are no matches
385 *
386 */
387 public Set<HostInstance> getAllValuesOfHost() {
388 return rawStreamAllValuesOfHost(emptyArray()).collect(Collectors.toSet());
389 }
390
391 /**
392 * Retrieve the set of values that occur in matches for Host.
393 * @return the Set of all values or empty set if there are no matches
394 *
395 */
396 public Stream<HostInstance> streamAllValuesOfHost() {
397 return rawStreamAllValuesOfHost(emptyArray());
398 }
399
400 @Override
401 protected NotEnoughAvailableMemory.Match tupleToMatch(final Tuple t) {
402 try {
403 return NotEnoughAvailableMemory.Match.newMatch((HostInstance) t.get(POSITION_HOST));
404 } catch(ClassCastException e) {
405 LOGGER.error("Element(s) in tuple not properly typed!",e);
406 return null;
407 }
408 }
409
410 @Override
411 protected NotEnoughAvailableMemory.Match arrayToMatch(final Object[] match) {
412 try {
413 return NotEnoughAvailableMemory.Match.newMatch((HostInstance) match[POSITION_HOST]);
414 } catch(ClassCastException e) {
415 LOGGER.error("Element(s) in array not properly typed!",e);
416 return null;
417 }
418 }
419
420 @Override
421 protected NotEnoughAvailableMemory.Match arrayToMatchMutable(final Object[] match) {
422 try {
423 return NotEnoughAvailableMemory.Match.newMutableMatch((HostInstance) match[POSITION_HOST]);
424 } catch(ClassCastException e) {
425 LOGGER.error("Element(s) in array not properly typed!",e);
426 return null;
427 }
428 }
429
430 /**
431 * @return the singleton instance of the query specification of this pattern
432 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
433 *
434 */
435 public static IQuerySpecification<NotEnoughAvailableMemory.Matcher> querySpecification() {
436 return NotEnoughAvailableMemory.instance();
437 }
438 }
439
440 private NotEnoughAvailableMemory() {
441 super(GeneratedPQuery.INSTANCE);
442 }
443
444 /**
445 * @return the singleton instance of the query specification
446 * @throws ViatraQueryRuntimeException if the pattern definition could not be loaded
447 *
448 */
449 public static NotEnoughAvailableMemory instance() {
450 try{
451 return LazyHolder.INSTANCE;
452 } catch (ExceptionInInitializerError err) {
453 throw processInitializerError(err);
454 }
455 }
456
457 @Override
458 protected NotEnoughAvailableMemory.Matcher instantiate(final ViatraQueryEngine engine) {
459 return NotEnoughAvailableMemory.Matcher.on(engine);
460 }
461
462 @Override
463 public NotEnoughAvailableMemory.Matcher instantiate() {
464 return NotEnoughAvailableMemory.Matcher.create();
465 }
466
467 @Override
468 public NotEnoughAvailableMemory.Match newEmptyMatch() {
469 return NotEnoughAvailableMemory.Match.newEmptyMatch();
470 }
471
472 @Override
473 public NotEnoughAvailableMemory.Match newMatch(final Object... parameters) {
474 return NotEnoughAvailableMemory.Match.newMatch((hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance) parameters[0]);
475 }
476
477 /**
478 * Inner class allowing the singleton instance of {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory (visibility: PUBLIC, simpleName: NotEnoughAvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory, 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
479 * <b>not</b> at the class load time of the outer class,
480 * but rather at the first call to {@link JvmGenericType: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory (visibility: PUBLIC, simpleName: NotEnoughAvailableMemory, identifier: hu.bme.mit.inf.dslreasoner.domains.cps.queries.NotEnoughAvailableMemory, deprecated: <unset>) (abstract: false, static: false, final: true, packageName: hu.bme.mit.inf.dslreasoner.domains.cps.queries) (interface: false, strictFloatingPoint: false, anonymous: false)#instance()}.
481 *
482 * <p> This workaround is required e.g. to support recursion.
483 *
484 */
485 private static class LazyHolder {
486 private static final NotEnoughAvailableMemory INSTANCE = new NotEnoughAvailableMemory();
487
488 /**
489 * Statically initializes the query specification <b>after</b> the field {@link #INSTANCE} is assigned.
490 * This initialization order is required to support indirect recursion.
491 *
492 * <p> The static initializer is defined using a helper field to work around limitations of the code generator.
493 *
494 */
495 private static final Object STATIC_INITIALIZER = ensureInitialized();
496
497 public static Object ensureInitialized() {
498 INSTANCE.ensureInitializedInternal();
499 return null;
500 }
501 }
502
503 private static class GeneratedPQuery extends BaseGeneratedEMFPQuery {
504 private static final NotEnoughAvailableMemory.GeneratedPQuery INSTANCE = new GeneratedPQuery();
505
506 private final PParameter parameter_Host = new PParameter("Host", "hu.bme.mit.inf.dslreasoner.domains.cps.HostInstance", new EClassTransitiveInstancesKey((EClass)getClassifierLiteralSafe("http://www.example.org/cps", "HostInstance")), PParameterDirection.INOUT);
507
508 private final List<PParameter> parameters = Arrays.asList(parameter_Host);
509
510 private GeneratedPQuery() {
511 super(PVisibility.PUBLIC);
512 }
513
514 @Override
515 public String getFullyQualifiedName() {
516 return "hu.bme.mit.inf.dslreasoner.domains.cps.queries.notEnoughAvailableMemory";
517 }
518
519 @Override
520 public List<String> getParameterNames() {
521 return Arrays.asList("Host");
522 }
523
524 @Override
525 public List<PParameter> getParameters() {
526 return parameters;
527 }
528
529 @Override
530 public Set<PBody> doGetContainedBodies() {
531 setEvaluationHints(new QueryEvaluationHint(null, QueryEvaluationHint.BackendRequirement.UNSPECIFIED));
532 Set<PBody> bodies = new LinkedHashSet<>();
533 {
534 PBody body = new PBody(this);
535 PVariable var_Host = body.getOrCreateVariableByName("Host");
536 PVariable var_Memory = body.getOrCreateVariableByName("Memory");
537 new TypeConstraint(body, Tuples.flatTupleOf(var_Host), new EClassTransitiveInstancesKey((EClass)getClassifierLiteral("http://www.example.org/cps", "HostInstance")));
538 body.setSymbolicParameters(Arrays.<ExportedParameter>asList(
539 new ExportedParameter(body, var_Host, parameter_Host)
540 ));
541 // find availableMemory(Host, Memory)
542 new PositivePatternCall(body, Tuples.flatTupleOf(var_Host, var_Memory), AvailableMemory.instance().getInternalQueryRepresentation());
543 // check(Memory < 0)
544 new ExpressionEvaluation(body, new IExpressionEvaluator() {
545
546 @Override
547 public String getShortDescription() {
548 return "Expression evaluation from pattern notEnoughAvailableMemory";
549 }
550
551 @Override
552 public Iterable<String> getInputParameterNames() {
553 return Arrays.asList("Memory");}
554
555 @Override
556 public Object evaluateExpression(IValueProvider provider) throws Exception {
557 Integer Memory = (Integer) provider.getValue("Memory");
558 return evaluateExpression_1_1(Memory);
559 }
560 }, null);
561 bodies.add(body);
562 }
563 {
564 PAnnotation annotation = new PAnnotation("Constraint");
565 annotation.addAttribute("severity", "error");
566 annotation.addAttribute("key", Arrays.asList(new Object[] {
567 new ParameterReference("Host")
568 }));
569 annotation.addAttribute("message", "Insufficient memory available on host.");
570 addAnnotation(annotation);
571 }
572 return bodies;
573 }
574 }
575
576 private static boolean evaluateExpression_1_1(final Integer Memory) {
577 return ((Memory).intValue() < 0);
578 }
579}