Class AbstractSwitch<T>

java.lang.Object
io.quarkus.gizmo.BytecodeCreatorImpl
io.quarkus.gizmo.AbstractSwitch<T>
All Implemented Interfaces:
BytecodeCreator, Switch<T>, AutoCloseable
Direct Known Subclasses:
EnumSwitchImpl, StringSwitchImpl

abstract class AbstractSwitch<T> extends BytecodeCreatorImpl implements Switch<T>
  • Field Details

    • fallThrough

      protected boolean fallThrough
    • defaultBlock

      protected final BytecodeCreatorImpl defaultBlock
  • Constructor Details

  • Method Details

    • fallThrough

      public void fallThrough()
      Description copied from interface: Switch
      Enables fall through.

      By default, the fall through is disabled. A case block is treated as a switch rule block; i.e. it's not necessary to add the break statement to prevent the fall through. However, if fall through is enabled then a case block is treated as a labeled statement group; i.e. it's necessary to add the break statement to prevent the fall through.

      For example, if fall through is disabled then:

       
       StringSwitch s = method.stringSwitch(val);
             s.caseOf(List.of("boom", "foo"), bc -> {...});
       
       
      is an equivalent of:
       switch (val) {
           case "boom", "foo" -> // statements provided by the consumer
       }
       
      However, if fall though is enabled then:
       
       StringSwitch s = method.stringSwitch(val);
       s.fallThrough();
       s.caseOf(List.of("boom", "foo"), bc -> {...});
       
       
      is an equivalent of:
       switch (val) {
           case "val1":
           case "val2":
               // statements provided by the consumer
       }
       
      Specified by:
      fallThrough in interface Switch<T>
    • defaultCase

      public void defaultCase(Consumer<BytecodeCreator> defatultBlockConsumer)
      Description copied from interface: Switch
      Adds the default block.
      Specified by:
      defaultCase in interface Switch<T>
      Parameters:
      defatultBlockConsumer -
    • doBreak

      public void doBreak(BytecodeCreator creator)
      Description copied from interface: Switch
      Writes bytecode into the provided BytecodeCreator to make it exit the switch, effectively issuing a Java 'break' statement.
      Specified by:
      doBreak in interface Switch<T>
      Parameters:
      creator -
      See Also: