Class AlternativeExpression


  • public class AlternativeExpression
    extends Expression
    Represents a VIL alternative.
    Author:
    Holger Eichelberger
    • Constructor Detail

      • AlternativeExpression

        AlternativeExpression()
        Constructor for serialization.
      • AlternativeExpression

        public AlternativeExpression​(Expression condition,
                                     IRuleBlock ifPart,
                                     IRuleBlock elsePart)
                              throws VilException
        Creates an alternative expression.
        Parameters:
        condition - the condition to be evaluated
        ifPart - the if-part to be executed if the alternative is true
        elsePart - the optional else-part to be executed if the alternative is false
        Throws:
        VilException - in case of syntactic or semantic problems
    • Method Detail

      • getCondition

        public Expression getCondition()
        Returns the condition to be evaluated.
        Returns:
        the condition
      • getIfPart

        public IRuleBlock getIfPart()
        Returns the if-part to be executed if the condition is false.
        Returns:
        the if-part
      • getElsePart

        public IRuleBlock getElsePart()
        Returns the else-part to be executed if the condition is false.
        Returns:
        the else-part
      • inferType

        public TypeDescriptor<?> inferType()
                                    throws VilException
        Description copied from class: Expression
        Infers the type of this expression including the type of the contained sub-expressions.
        Specified by:
        inferType in class Expression
        Returns:
        the type of this expression
        Throws:
        VilException - in case that inferring the type fails
      • accept

        public java.lang.Object accept​(IExpressionVisitor visitor)
                                throws VilException
        Description copied from class: Expression
        Visits the expression.
        Specified by:
        accept in class Expression
        Parameters:
        visitor - the visitor
        Returns:
        the result of visiting this expression (may be null)
        Throws:
        VilException - in case that visiting fails (e.g., execution)