Class AlternativeStatement
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.templateModel.AbstractTemplateElement
-
- net.ssehub.easy.instantiation.core.model.templateModel.AlternativeStatement
-
- All Implemented Interfaces:
ILanguageElement,ITemplateElement,ITemplateLangElement
public class AlternativeStatement extends AbstractTemplateElement
Representation of an alternative-statement in VIL templates which allows conditional processing of two template language statements or blocks (if-then-else).- Author:
- kroeher
-
-
Field Summary
Fields Modifier and Type Field Description private Expressionconditionprivate ITemplateElementelseStatementprivate ITemplateElementifStatement
-
Constructor Summary
Constructors Constructor Description AlternativeStatement()Constructor for serialization.AlternativeStatement(Expression condition, ITemplateElement ifStatement)Create an alternative-statement with a single if-block only.AlternativeStatement(Expression condition, ITemplateElement ifStatement, ITemplateElement elseStatement)Create an alternative-statement with an if-block and an else-block.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Objectaccept(IVisitor visitor)Accepts the visitor for visiting.booleanendsWithContentStatement()Returns whether this element ends with a content statement.ExpressiongetCondition()Get the condition of this alternative.ITemplateElementgetElseStatement()Get the else-statement of this alternative.ITemplateElementgetIfStatement()Get the if-statement of this alternative.TypeDescriptor<?>inferType()Infers the type of this language element.booleanisBlock()Returns whether this element is a block (opposite is a single statement).-
Methods inherited from class net.ssehub.easy.instantiation.core.model.templateModel.AbstractTemplateElement
getParent, isLoop, setParent
-
-
-
-
Field Detail
-
condition
private Expression condition
-
ifStatement
private ITemplateElement ifStatement
-
elseStatement
private ITemplateElement elseStatement
-
-
Constructor Detail
-
AlternativeStatement
AlternativeStatement()
Constructor for serialization.
-
AlternativeStatement
public AlternativeStatement(Expression condition, ITemplateElement ifStatement) throws VilException
Create an alternative-statement with a single if-block only.- Parameters:
condition- The condition which must be evaluated to true to process the if-block.ifStatement- The if-statement which subsumes a set of template elements that will only be processed if the condition is evaluated to true.- Throws:
VilException- in case that the construction fails due to semantic problems
-
AlternativeStatement
public AlternativeStatement(Expression condition, ITemplateElement ifStatement, ITemplateElement elseStatement) throws VilException
Create an alternative-statement with an if-block and an else-block.- Parameters:
condition- The condition of this alternative. If evaluated to true the if-block will be processed. If evaluated to false the else-block will be processed.ifStatement- The if-block which subsumes a set of template elements that will only be processed if the condition is evaluated to true.elseStatement- The else-block which subsumes a set of template elements that will only be processed if the condition is evaluated to false.- Throws:
VilException- in case that the construction fails due to semantic problems
-
-
Method Detail
-
getCondition
public Expression getCondition()
Get the condition of this alternative.- Returns:
- The condition expression of this alternative
-
getIfStatement
public ITemplateElement getIfStatement()
Get the if-statement of this alternative.- Returns:
- The template element that represents the if-statement of this alternative.
-
getElseStatement
public ITemplateElement getElseStatement()
Get the else-statement of this alternative.- Returns:
- The template element that represents the else-statement of this alternative or null if no else-statement is defined.
-
accept
public java.lang.Object accept(IVisitor visitor) throws VilException
Description copied from interface:ITemplateLangElementAccepts the visitor for visiting.- Parameters:
visitor- the visitor to be used- Returns:
- the result of visiting this instance (may be null)
- Throws:
VilException- in case that visiting fails (e.g., execution)
-
isBlock
public boolean isBlock()
Description copied from interface:ITemplateElementReturns whether this element is a block (opposite is a single statement).- Returns:
trueif it is a block,falseelse
-
inferType
public TypeDescriptor<?> inferType() throws VilException
Description copied from interface:ITemplateElementInfers the type of this language element.- Returns:
- the type of this language element
- Throws:
VilException- in case that type errors occur
-
endsWithContentStatement
public boolean endsWithContentStatement()
Description copied from interface:ITemplateElementReturns whether this element ends with a content statement.- Returns:
truefor end with content statement,falseelse
-
-