Package io.quarkus.gizmo
Class AbstractSwitch<T>
- java.lang.Object
-
- io.quarkus.gizmo.BytecodeCreatorImpl
-
- io.quarkus.gizmo.AbstractSwitch<T>
-
- All Implemented Interfaces:
BytecodeCreator,Switch<T>,java.lang.AutoCloseable
- Direct Known Subclasses:
EnumSwitchImpl,StringSwitchImpl
abstract class AbstractSwitch<T> extends BytecodeCreatorImpl implements Switch<T>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.quarkus.gizmo.BytecodeCreatorImpl
BytecodeCreatorImpl.AssignOperation, BytecodeCreatorImpl.BlockOperation, BytecodeCreatorImpl.IfOperation, BytecodeCreatorImpl.InvokeOperation, BytecodeCreatorImpl.JumpOperation, BytecodeCreatorImpl.NewInstanceOperation, BytecodeCreatorImpl.Operation
-
Nested classes/interfaces inherited from interface io.quarkus.gizmo.Switch
Switch.EnumSwitch<E extends java.lang.Enum<E>>, Switch.StringSwitch
-
-
Field Summary
Fields Modifier and Type Field Description protected BytecodeCreatorImpldefaultBlockprotected booleanfallThrough-
Fields inherited from class io.quarkus.gizmo.BytecodeCreatorImpl
MAX_STRING_LENGTH, operations
-
-
Constructor Summary
Constructors Constructor Description AbstractSwitch(BytecodeCreatorImpl enclosing)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddefaultCase(java.util.function.Consumer<BytecodeCreator> defatultBlockConsumer)Adds the default block.voiddoBreak(BytecodeCreator creator)Writes bytecode into the providedBytecodeCreatorto make it exit the switch, effectively issuing a Java 'break' statement.voidfallThrough()Enables fall through.-
Methods inherited from class io.quarkus.gizmo.BytecodeCreatorImpl
add, allocateLocalVariables, arrayLength, assign, bitwiseAnd, bitwiseOr, bitwiseXor, breakScope, checkCast, checkScope, checkScope, compareDouble, compareFloat, compareLong, continueScope, convertPrimitive, createFunction, createNewInstanceOp, createScope, createVariable, divide, enumSwitch, findActiveResultHandles, forEach, getBottom, getMethod, getMethodParam, getOwner, getThis, getTop, ifFalse, ifGreaterEqualZero, ifGreaterThanZero, ifIntegerEqual, ifIntegerGreaterEqual, ifIntegerGreaterThan, ifIntegerLessEqual, ifIntegerLessThan, ifLessEqualZero, ifLessThanZero, ifNonZero, ifNotNull, ifNull, ifReferencesEqual, ifReferencesNotEqual, ifThenElse, ifTrue, ifZero, instanceOf, invokeInterfaceMethod, invokeSpecialInterfaceMethod, invokeSpecialMethod, invokeStaticInterfaceMethod, invokeStaticMethod, invokeVirtualMethod, isScopedWithin, jumpTo, load, load, load, load, load, load, load, load, load, loadClass, loadClassFromTCCL, loadNull, loadResultHandle, loadResultHandle, multiply, newArray, newInstance, readArrayValue, readInstanceField, readStaticField, remainder, resolve, resolve, resolve, resolve, returnValue, storeResultHandle, stringSwitch, subtract, throwException, tryBlock, whileLoop, writeArrayValue, writeInstanceField, writeInteriorOperations, writeOperations, writeStaticField
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.quarkus.gizmo.BytecodeCreator
breakScope, checkCast, close, continueScope, createVariable, increment, instanceOf, invokeInterfaceMethod, invokeSpecialInterfaceMethod, invokeSpecialMethod, invokeStaticInterfaceMethod, invokeStaticMethod, invokeVirtualMethod, load, loadClass, loadClass, loadClassFromTCCL, loadClassFromTCCL, marshalAsArray, newArray, newArray, newArray, newInstance, readArrayValue, readInstanceField, readStaticField, returnBoolean, returnInt, returnNull, returnVoid, throwException, throwException, writeArrayValue, writeInstanceField, writeStaticField
-
-
-
-
Field Detail
-
fallThrough
protected boolean fallThrough
-
defaultBlock
protected final BytecodeCreatorImpl defaultBlock
-
-
Constructor Detail
-
AbstractSwitch
AbstractSwitch(BytecodeCreatorImpl enclosing)
-
-
Method Detail
-
fallThrough
public void fallThrough()
Description copied from interface:SwitchEnables 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:
is an equivalent of:StringSwitch s = method.stringSwitch(val); s.caseOf(List.of("boom", "foo"), bc -> {...});switch (val) { case "boom", "foo" -> // statements provided by the consumer }However, if fall though is enabled then:
is an equivalent of:StringSwitch s = method.stringSwitch(val); s.fallThrough(); s.caseOf(List.of("boom", "foo"), bc -> {...});switch (val) { case "val1": case "val2": // statements provided by the consumer }- Specified by:
fallThroughin interfaceSwitch<T>
-
defaultCase
public void defaultCase(java.util.function.Consumer<BytecodeCreator> defatultBlockConsumer)
Description copied from interface:SwitchAdds the default block.- Specified by:
defaultCasein interfaceSwitch<T>
-
doBreak
public void doBreak(BytecodeCreator creator)
Description copied from interface:SwitchWrites bytecode into the providedBytecodeCreatorto make it exit the switch, effectively issuing a Java 'break' statement.- Specified by:
doBreakin interfaceSwitch<T>- See Also:
Switch.fallThrough()
-
-