Package io.quarkus.gizmo
Interface IfThenElse
-
- All Known Implementing Classes:
IfThenElseImpl
public interface IfThenElseAn if-then-else construct.This construct is not thread-safe and should not be re-used.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description BytecodeCreatorelseIf(ResultHandle condition)Creates a new else-if statement.BytecodeCreatorelseIf(java.util.function.Function<BytecodeCreator,ResultHandle> test)Creates a new else-if statement.BytecodeCreatorelseThen()This block is executed if no condition result handle was evaluated astrue.BytecodeCreatorthen()This block is executed if the result handle that was passed toBytecodeCreator.ifThenElse(ResultHandle)is evaluated astrue.
-
-
-
Method Detail
-
then
BytecodeCreator then()
This block is executed if the result handle that was passed toBytecodeCreator.ifThenElse(ResultHandle)is evaluated astrue.- Returns:
- the
thenblock
-
elseIf
BytecodeCreator elseIf(ResultHandle condition)
Creates a new else-if statement. The block is executed if the condition result handle is evaluated astrue.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 theelseIf(Function)method instead.- Parameters:
condition-- Returns:
- the
else-ifblock
-
elseIf
BytecodeCreator elseIf(java.util.function.Function<BytecodeCreator,ResultHandle> test)
Creates a new else-if statement. The block is executed if the condition result handle returned from the function is evaluated astrue.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"
- Parameters:
test-- Returns:
- the
else-ifblock
-
elseThen
BytecodeCreator elseThen()
This block is executed if no condition result handle was evaluated astrue.- Returns:
- the
elseblock
-
-