Class AbstractSwitch<T>

    • Field Detail

      • fallThrough

        protected boolean fallThrough
    • Method Detail

      • 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​(java.util.function.Consumer<BytecodeCreator> defatultBlockConsumer)
        Description copied from interface: Switch
        Adds the default block.
        Specified by:
        defaultCase in interface Switch<T>