Class Signatures

java.lang.Object
com.vaadin.hilla.parser.utils.Signatures

public final class Signatures extends Object
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:

  • Method Details

    • of

      public static AnnotatedType of(@NonNull Class<?> cls)
      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

      public static AnnotatedType withClass(@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.
      Parameters:
      type - the class reference to take the type arguments and annotations from
      cls - the class to refer to instead
      Returns:
      the signature referring to the class
    • getAnnotations

      public static List<Annotation> getAnnotations(@NonNull AnnotatedElement signature)
      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

      public static Optional<Class<?>> getClass(@NonNull AnnotatedElement signature)
      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

      public static List<AnnotatedType> getTypeArguments(@NonNull AnnotatedElement signature)
      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

      public static List<AnnotatedType> getBounds(@NonNull AnnotatedWildcardType wildcard)
      The types a wildcard type argument is bound by, except Object, which bounds a wildcard that says nothing.
      Parameters:
      wildcard - the wildcard
      Returns:
      the lower bounds followed by the upper bounds
    • getBounds

      public static List<AnnotatedType> getBounds(@NonNull TypeVariable<?> typeParameter)
      The types a type parameter is bound by.
      Parameters:
      typeParameter - the type parameter
      Returns:
      the bounds
    • resolve

      public static TypeVariable<?> resolve(@NonNull AnnotatedTypeVariable typeVariable)
      The type parameter a type variable stands for.
      Parameters:
      typeVariable - the type variable
      Returns:
      the type parameter declaring it
    • isArray

      public static boolean isArray(AnnotatedElement signature)
    • isBase

      public static boolean isBase(AnnotatedElement signature)
    • isClassRef

      public static boolean isClassRef(AnnotatedElement signature)
    • isTypeArgument

      public static boolean isTypeArgument(AnnotatedElement signature)
    • isTypeParameter

      public static boolean isTypeParameter(AnnotatedElement signature)
    • isTypeVariable

      public static boolean isTypeVariable(AnnotatedElement signature)
    • isBigDecimal

      public static boolean isBigDecimal(AnnotatedElement signature)
    • isBigInteger

      public static boolean isBigInteger(AnnotatedElement signature)
    • isBoolean

      public static boolean isBoolean(AnnotatedElement signature)
    • isByte

      public static boolean isByte(AnnotatedElement signature)
    • isCharacter

      public static boolean isCharacter(AnnotatedElement signature)
    • isDate

      public static boolean isDate(AnnotatedElement signature)
    • isDateTime

      public static boolean isDateTime(AnnotatedElement signature)
    • isDouble

      public static boolean isDouble(AnnotatedElement signature)
    • isEnum

      public static boolean isEnum(AnnotatedElement signature)
    • isFloat

      public static boolean isFloat(AnnotatedElement signature)
    • isInteger

      public static boolean isInteger(AnnotatedElement signature)
    • isIterable

      public static boolean isIterable(AnnotatedElement signature)
    • isLong

      public static boolean isLong(AnnotatedElement signature)
    • isMap

      public static boolean isMap(AnnotatedElement signature)
    • isNativeObject

      public static boolean isNativeObject(AnnotatedElement signature)
    • isOptional

      public static boolean isOptional(AnnotatedElement signature)
    • isShort

      public static boolean isShort(AnnotatedElement signature)
    • isString

      public static boolean isString(AnnotatedElement signature)
    • isPrimitive

      public static boolean isPrimitive(AnnotatedElement signature)
    • isVoid

      public static boolean isVoid(AnnotatedElement signature)
    • hasFloatType

      public static boolean hasFloatType(AnnotatedElement signature)
    • hasIntegerType

      public static boolean hasIntegerType(AnnotatedElement signature)
    • isJDKClass

      public static boolean isJDKClass(AnnotatedElement signature)
      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:
      true if the signature refers to a JDK class
    • isNonJDKClass

      public static boolean isNonJDKClass(AnnotatedElement signature)
    • isJDKClass

      public static boolean isJDKClass(Class<?> cls)
    • isJDKClass

      public static boolean isJDKClass(String name)
    • isAssignableFrom

      public static boolean isAssignableFrom(String target, Class<?> actor)
      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 for
      actor - the class to check
      Returns:
      true if the class is or extends the named class