Class IfThenElseImpl

    • Field Detail

      • state

        private byte state
      • INIT

        private static byte INIT
      • THEN

        private static byte THEN
      • ELSEIF

        private static byte ELSEIF
      • ELSE

        private static byte ELSE
    • Method Detail

      • elseIf

        public BytecodeCreator elseIf​(ResultHandle value)
        Description copied from interface: IfThenElse
        Creates a new else-if statement. The block is executed if the condition result handle is evaluated as true.

        Note that the condition result handle must already exist.

         boolean test = foo.testIsOk();
         if (someOtherCondition) {
             // do action "A"
         } else if (test) {
             // do action "B"
         }
         
        If you need to create the condition result handle inside the if-else statement then use the IfThenElse.elseIf(Function) method instead.
        Specified by:
        elseIf in interface IfThenElse
        Returns:
        the else-if block
      • elseIf

        public BytecodeCreator elseIf​(java.util.function.Function<BytecodeCreator,​ResultHandle> test)
        Description copied from interface: IfThenElse
        Creates a new else-if statement. The block is executed if the condition result handle returned from the function is evaluated as true.

        The argument of the function represents the block that is executed when the else-if statement is evaluated.

        In order to generate the bytecode for the "action B" branch in the following example:

         if (someOtherCondition) {
             // do action "A"
         } else if (foo.testIsOk()) {
             // do action "B"
         }
         
        The code needs to look like:
         IfThenElse ifAction = method.ifThenElse(someOtherCondition);
         BytecodeCreator ifTestOk = ifValue.elseIf(b -> b.invokeVirtualMethod(testIsOkMethodDescriptor, fooInstance)));
         // do action "B"
         
        Specified by:
        elseIf in interface IfThenElse
        Returns:
        the else-if block
      • elseThen

        public BytecodeCreator elseThen()
        Description copied from interface: IfThenElse
        This block is executed if no condition result handle was evaluated as true.
        Specified by:
        elseThen in interface IfThenElse
        Returns:
        the else block
      • initialThenNotCreated

        private java.lang.IllegalStateException initialThenNotCreated()
      • elseAlreadyCreated

        private java.lang.IllegalStateException elseAlreadyCreated()