Class SwitchKeys
java.lang.Object
io.micronaut.sourcegen.bytecode.core.SwitchKeys
The switches both bytecode writers write as a switch on an
int, as javac writes them: a selector of type
int, char, short or byte is widened to an int, and one of their wrappers is
unboxed first, which throws NullPointerException for null.- Since:
- 2.3
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable Integerkey(ExpressionDef.Constant constant) Theinta case constant of a switch on anintmatches.static booleanswitchesOnInt(TypeDef selector) Whether a switch on a selector of a type is a switch on theintit widens or unboxes to.
-
Method Details
-
switchesOnInt
Whether a switch on a selector of a type is a switch on theintit widens or unboxes to.- Parameters:
selector- The type of the selector- Returns:
- true for an
int, achar, ashort, abyteand their wrappers
-
key
Theinta case constant of a switch on anintmatches.- Parameters:
constant- The constant of the case- Returns:
- The key, or
nullfor a constant that is noint,char,shortorbyte
-