Package com.vaadin.hilla.parser.utils
Class Signatures
java.lang.Object
com.vaadin.hilla.parser.utils.Signatures
Tells what a type signature the parser walks stands for.
A type signature is the reflection object a typed node of the walk holds: an
AnnotatedType where a type is used, such as the type of a field or a
type argument of it, and a TypeVariable where a type parameter is
declared. An annotated type is one of these kinds:
- a class reference: a class or an interface, with or without type
arguments (
isClassRef(AnnotatedElement)) - a primitive type,
voidincluded (isBase(AnnotatedElement)) - an array (
AnnotatedArrayType) - a type variable (
AnnotatedTypeVariable) - a wildcard type argument (
AnnotatedWildcardType)
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<Annotation> getAnnotations(@NonNull AnnotatedElement signature) The annotations the signature is used with, or, for a type parameter, the annotations it is declared with.static List<AnnotatedType> getBounds(@NonNull AnnotatedWildcardType wildcard) The types a wildcard type argument is bound by, exceptObject, which bounds a wildcard that says nothing.static List<AnnotatedType> getBounds(@NonNull TypeVariable<?> typeParameter) The types a type parameter is bound by.getClass(@NonNull AnnotatedElement signature) The class a class reference or a primitive type refers to.static List<AnnotatedType> getTypeArguments(@NonNull AnnotatedElement signature) The type arguments of a class reference.static booleanhasFloatType(AnnotatedElement signature) static booleanhasIntegerType(AnnotatedElement signature) static booleanisArray(AnnotatedElement signature) static booleanisAssignableFrom(String target, Class<?> actor) Whether a class is the named class or extends it.static booleanisBase(AnnotatedElement signature) static booleanisBigDecimal(AnnotatedElement signature) static booleanisBigInteger(AnnotatedElement signature) static booleanisBoolean(AnnotatedElement signature) static booleanisByte(AnnotatedElement signature) static booleanisCharacter(AnnotatedElement signature) static booleanisClassRef(AnnotatedElement signature) static booleanisDate(AnnotatedElement signature) static booleanisDateTime(AnnotatedElement signature) static booleanisDouble(AnnotatedElement signature) static booleanisEnum(AnnotatedElement signature) static booleanisFloat(AnnotatedElement signature) static booleanisInteger(AnnotatedElement signature) static booleanisIterable(AnnotatedElement signature) static booleanisJDKClass(Class<?> cls) static booleanisJDKClass(AnnotatedElement signature) Whether a signature refers to a class of the JDK.static booleanisJDKClass(String name) static booleanisLong(AnnotatedElement signature) static booleanisMap(AnnotatedElement signature) static booleanisNativeObject(AnnotatedElement signature) static booleanisNonJDKClass(AnnotatedElement signature) static booleanisOptional(AnnotatedElement signature) static booleanisPrimitive(AnnotatedElement signature) static booleanisShort(AnnotatedElement signature) static booleanisString(AnnotatedElement signature) static booleanisTypeArgument(AnnotatedElement signature) static booleanisTypeParameter(AnnotatedElement signature) static booleanisTypeVariable(AnnotatedElement signature) static booleanisVoid(AnnotatedElement signature) static AnnotatedTypeCreates the signature of a class used without annotations or type arguments, for a type reflection gives as a class only.static TypeVariable<?> resolve(@NonNull AnnotatedTypeVariable typeVariable) The type parameter a type variable stands for.static AnnotatedTypewithClass(@NonNull AnnotatedType type, @NonNull Class<?> cls) Creates the signature of a class reference which refers to another class than the given one, keeping its type arguments and annotations.
-
Method Details
-
of
Creates the signature of a class used without annotations or type arguments, for a type reflection gives as a class only.- Parameters:
cls- the class- Returns:
- the signature of the class
-
withClass
Creates the signature of a class reference which refers to another class than the given one, keeping its type arguments and annotations.- Parameters:
type- the class reference to take the type arguments and annotations fromcls- the class to refer to instead- Returns:
- the signature referring to the class
-
getAnnotations
The annotations the signature is used with, or, for a type parameter, the annotations it is declared with.- Parameters:
signature- the signature- Returns:
- the annotations
-
getClass
The class a class reference or a primitive type refers to.- Parameters:
signature- the signature- Returns:
- the class, or empty for any other kind of signature
-
getTypeArguments
The type arguments of a class reference.- Parameters:
signature- the signature- Returns:
- the type arguments, or an empty list for a signature which has none
-
getBounds
The types a wildcard type argument is bound by, exceptObject, which bounds a wildcard that says nothing.- Parameters:
wildcard- the wildcard- Returns:
- the lower bounds followed by the upper bounds
-
getBounds
The types a type parameter is bound by.- Parameters:
typeParameter- the type parameter- Returns:
- the bounds
-
resolve
The type parameter a type variable stands for.- Parameters:
typeVariable- the type variable- Returns:
- the type parameter declaring it
-
isArray
-
isBase
-
isClassRef
-
isTypeArgument
-
isTypeParameter
-
isTypeVariable
-
isBigDecimal
-
isBigInteger
-
isBoolean
-
isByte
-
isCharacter
-
isDate
-
isDateTime
-
isDouble
-
isEnum
-
isFloat
-
isInteger
-
isIterable
-
isLong
-
isMap
-
isNativeObject
-
isOptional
-
isShort
-
isString
-
isPrimitive
-
isVoid
-
hasFloatType
-
hasIntegerType
-
isJDKClass
Whether a signature refers to a class of the JDK. A primitive type counts as one; an array, a type variable, a type parameter and a wildcard do not.- Parameters:
signature- the signature- Returns:
trueif the signature refers to a JDK class
-
isNonJDKClass
-
isJDKClass
-
isJDKClass
-
isAssignableFrom
Whether a class is the named class or extends it. Only the superclasses are checked, not the interfaces.- Parameters:
target- the name of the class to look foractor- the class to check- Returns:
trueif the class is or extends the named class
-