public interface EvaluableExpression
EvaluableVariable
s and a
double
value. Expressions will usually combine other expressions, called
contained expressions. This implements the well-known composite pattern. An
expression is said to contain all expressions that are used to calculate its
value or are contained by any these. Some contained expression will usually be
EvaluableVariable
s. Most expressions will define a requirement on the minimum
and/or maximum amount of contained evaluable expressions. An expression can be
evaluated by calling evaluate(EvaluableVariableAssignment)
.
Note that expressions cannot not contain themselves.
Implementations are encouraged to override Object.equals(Object)
and
Object.hashCode()
to fulfill the following: If for two evaluable expressions
a
and b
a.equals(b)
returns true
true,
a.evaluate(ass)
will return a value equal to b.evaluate(ass)
for any
EvaluableVariableAssignment
ass
. The inverse implication will usually
not hold, e.g. for most cases, there will be two evaluable expressions c
and
d
for which c.evaluate(ass)
returns a value equal to
d.evaluate(ass)
for any EvaluableVariableAssignment
ass
but
a.equals(b)
returns false
. However, the implementation of
equals
should aim to allow as few such pairs (c,d)
as possible.
Users should be aware that calling EvaluableExpression#equals(Object)
may be very costly, as it might require a lot of
comparisons and expressions may an unlimited amount of contained expressions.
Modifier and Type | Field and Description |
---|---|
static double |
FALSE
The used value to express
true as double. |
Modifier and Type | Method and Description |
---|---|
double |
evaluate(EvaluableVariableAssignment variableAssignments)
Calculates this expression’s value for the given
variableAssignments . |
void |
receive(EvaluableExpressionVisitor visitor)
Calls the appropriate overload of
EvaluableExpressionVisitor.visit(de.uka.ipd.sdq.beagle.core.evaluableexpressions.AdditionExpression) on
visitor . |
static final double FALSE
true
as double.void receive(EvaluableExpressionVisitor visitor)
EvaluableExpressionVisitor.visit(de.uka.ipd.sdq.beagle.core.evaluableexpressions.AdditionExpression)
on
visitor
. This implements the well-known visitor pattern.visitor
- The visitor wishing to visit this expression.double evaluate(EvaluableVariableAssignment variableAssignments)
variableAssignments
.variableAssignments
- must assign a value to at least all
EvaluableVariable
s contained in this expression.