Class SwitchStatement.Alternative
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.templateModel.SwitchStatement.Alternative
-
- Enclosing class:
- SwitchStatement
public static class SwitchStatement.Alternative extends java.lang.ObjectA switch alternative.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private Expressionconditionprivate Expressionvalue
-
Constructor Summary
Constructors Constructor Description Alternative()Constructor for serialization.Alternative(Expression value)Creates the default alternative.Alternative(Expression condition, Expression value)Creates an alternative.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExpressiongetCondition()Returns the alternative condition.ExpressiongetValue()Returns the resulting value if the alternative is considered valid.TypeDescriptor<?>inferType()Infers the type of this alternative based on its value.booleanisDefault()Whether this alternative is the default.
-
-
-
Field Detail
-
condition
private Expression condition
-
value
private Expression value
-
-
Constructor Detail
-
Alternative
Alternative()
Constructor for serialization.
-
Alternative
public Alternative(Expression value)
Creates the default alternative.- Parameters:
value- the resulting value
-
Alternative
public Alternative(Expression condition, Expression value)
Creates an alternative.- Parameters:
condition- an expression to be checked against the switch expressionvalue- the resulting value if the alternative is valid
-
-
Method Detail
-
getCondition
public Expression getCondition()
Returns the alternative condition.- Returns:
- the condition
-
getValue
public Expression getValue()
Returns the resulting value if the alternative is considered valid.- Returns:
- the value (expression)
-
isDefault
public boolean isDefault()
Whether this alternative is the default.- Returns:
trueif it is the default,falseelse
-
inferType
public TypeDescriptor<?> inferType() throws VilException
Infers the type of this alternative based on its value.- Returns:
- the type of the alternative
- Throws:
VilException- in case that type resolution fails
-
-