Class TypeSwitchCase

java.lang.Object
org.jfuncmachine.compiler.model.SourceElement
org.jfuncmachine.compiler.model.expr.TypeSwitchCase

public class TypeSwitchCase extends SourceElement
Defines a case value for a class switch statement containing a target value, an optional extra comparison, and an expression to be executed if the switch value matches the case value.
  • Field Details

    • target

      public final Object target
      The class (ObjectType value) that this case matches, or a string, or an int
    • additionalComparison

      public final BooleanExpr additionalComparison
      An additional expression to execute to check whether target matches this case value. @see "org.jfuncmachine.compiler.expr.TypeSwitch" This value can be null.
    • expr

      public final Expression expr
      The expression to execute if the switch value equals this case value
  • Constructor Details

    • TypeSwitchCase

      public TypeSwitchCase(String target, Expression expr)
      Create a switch case for a string target
      Parameters:
      target - The String to match against the switch target
      expr - The expression to execute if the switch value equals this case value
    • TypeSwitchCase

      public TypeSwitchCase(Integer target, Expression expr)
      Create a switch case for an integer target
      Parameters:
      target - The String to match against the switch target
      expr - The expression to execute if the switch value equals this case value
    • TypeSwitchCase

      public TypeSwitchCase(ObjectType target, Expression expr)
      Create a switch case for a class target
      Parameters:
      target - The String to match against the switch target
      expr - The expression to execute if the switch value equals this case value
    • TypeSwitchCase

      public TypeSwitchCase(String target, Expression expr, String filename, int lineNumber)
      Create a switch case for a string target
      Parameters:
      target - The String to match against the switch target
      expr - The expression to execute if the switch value equals this case value
      filename - The source filename containing this case
      lineNumber - The line number in the source filename where this case starts
    • TypeSwitchCase

      public TypeSwitchCase(Integer target, Expression expr, String filename, int lineNumber)
      Create a switch case for an integer target
      Parameters:
      target - The String to match against the switch target
      expr - The expression to execute if the switch value equals this case value
      filename - The source filename containing this case
      lineNumber - The line number in the source filename where this case starts
    • TypeSwitchCase

      public TypeSwitchCase(ObjectType target, Expression expr, String filename, int lineNumber)
      Create a switch case for a class target
      Parameters:
      target - The String to match against the switch target
      expr - The expression to execute if the switch value equals this case value
      filename - The source filename containing this case
      lineNumber - The line number in the source filename where this case starts
    • TypeSwitchCase

      public TypeSwitchCase(ObjectType target, BooleanExpr additionalComparison, Expression expr)
      Create a switch case
      Parameters:
      target - The class that this case matches
      additionalComparison - An additional comparison to execute to make sure the target matches this case
      expr - The expression to execute if the switch value equals this case value
    • TypeSwitchCase

      public TypeSwitchCase(ObjectType target, BooleanExpr additionalComparison, Expression expr, String filename, int lineNumber)
      Create a switch case
      Parameters:
      target - The class that this case matches
      additionalComparison - An additional comparison to execute to make sure the target matches this case
      expr - The expression to execute if the switch value equals this case value
      filename - The source filename containing this case
      lineNumber - The line number in the source filename where this case starts