Class AnnotationScalars
java.lang.Object
io.micronaut.python.processing.util.AnnotationScalars
Narrows a literal from the Python processor (a String, Boolean, Integer, Long or Double) to the
declared scalar annotation member type, the way the Java annotation processor would deliver it.
Python is more permissive than Java here:
value=True on a String member becomes
"true", and 1 on a long member becomes 1L.- Since:
- 5.2.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanA literal for a boolean member: a boolean, not a string.static charA literal for acharmember or array element: a one-character string, never a number or a boolean that happens to print as one character.static charA literal for acharmember: exactly one character, as in Java source.coerce(@Nullable Object value, @Nullable ClassElement memberType) static floatA literal for afloatmember: a finite value must not overflow to infinity, as javac rejects a constant too large for the type.static longA literal for an integral member, checked the way javac checks a constant: integral and in range.static NumberA literal for a numeric member: a number, not a string or a boolean that happens to parse.
-
Method Details
-
coerce
-
integral
A literal for an integral member, checked the way javac checks a constant: integral and in range.- Parameters:
number- The literalmin- The member type's minimummax- The member type's maximumtypeName- The member type, for the message- Returns:
- The value
-
floating
A literal for afloatmember: a finite value must not overflow to infinity, as javac rejects a constant too large for the type.- Parameters:
number- The literal- Returns:
- The float
-
number
-
bool
A literal for a boolean member: a boolean, not a string.- Parameters:
value- The literal- Returns:
- The boolean
-
character
A literal for acharmember: exactly one character, as in Java source.- Parameters:
string- The literal- Returns:
- The character
-
character
A literal for acharmember or array element: a one-character string, never a number or a boolean that happens to print as one character.- Parameters:
value- The literal- Returns:
- The character
-