Class SwitchStatement.Alternative

  • Enclosing class:
    SwitchStatement

    public static class SwitchStatement.Alternative
    extends java.lang.Object
    A switch alternative.
    Author:
    Holger Eichelberger
    • 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 expression
        value - 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:
        true if it is the default, false else
      • 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