public interface ExpressionBuilder
This interface provides methods to build a single expression consisting of PolyScope entities, such as
variables, Features, I/Os and/or waypoints, as well as string parts. Each expression being built must use
a new ExpressionBuilder
instance.
Expression expr = builder.appendVariable(var_1)
.append(" + ")
.appendVariable(var_2)
.append(" + 5")
.build();
The expression built will have information about the entities and their type (in the example the variables 'var_1' and
'var_2'). Should the entities for some reason not be present, the expression can still be valid but will be undefined.
This can be the case for, e.g. installation variables, if a different installation is loaded or the end user has deleted
the variable. When the variable is present again, the expression will become defined.Modifier and Type | Method and Description |
---|---|
ExpressionBuilder |
append(String expressionPart)
Append a string part of the expression.
|
ExpressionBuilder |
appendFeature(Feature feature)
Append a Feature object to the expression.
|
ExpressionBuilder |
appendIO(IO io)
Append an I/O object to the expression.
|
ExpressionBuilder |
appendVariable(Variable variable)
Append a variable object to the expression.
|
ExpressionBuilder |
appendWaypoint(WaypointNode waypoint)
Append a waypoint to the expression.
|
Expression |
build()
Build the expression consisting of all the appended parts.
|
ExpressionBuilder append(String expressionPart)
expressionPart
- the expression part to be appended.ExpressionBuilder appendVariable(Variable variable)
variable
- the variable to append.ExpressionBuilder appendFeature(Feature feature)
feature
- the Feature to appendExpressionBuilder appendWaypoint(WaypointNode waypoint)
waypoint
- the waypoint to appendExpressionBuilder appendIO(IO io)
io
- the I/O to append.Expression build() throws InvalidExpressionException
InvalidExpressionException
- if the expression is syntactically incorrect/invalid.Copyright © 2021. All rights reserved.