Class TypeArgument

java.lang.Object
io.helidon.codegen.classmodel.TypeArgument
All Implemented Interfaces:
Prototype.Api, Annotated, TypeName, Comparable<TypeName>

public final class TypeArgument extends Object implements TypeName
Generic type argument model.
  • Method Details

    • create

      public static TypeArgument create(String token)
      Creates new TypeArgument instance based on the provided token.
      Parameters:
      token - argument token
      Returns:
      new argument instance
    • create

      public static TypeArgument create(TypeName typeName)
      Creates a new instance from a generic type name.
      Parameters:
      typeName - type name to use
      Returns:
      a new type argument
    • builder

      public static TypeArgument.Builder builder()
      Return new TypeArgument.Builder instance.
      Returns:
      new builder instance
    • boxed

      public TypeName boxed()
      Description copied from interface: TypeName
      Return the boxed equivalent of this type. If this is not a primitive type, returns this instance.
      Specified by:
      boxed in interface TypeName
      Returns:
      boxed type for this type, or this type if not primitive
    • genericTypeName

      public TypeName genericTypeName()
      Description copied from interface: TypeName
      The base generic type name, stripped of any TypeName.typeArguments(). This is equivalent to the type name represented by TypeName.name().
      Specified by:
      genericTypeName in interface TypeName
      Returns:
      based generic type name
    • token

      public String token()
      Type argument token.
      Returns:
      token value
    • packageName

      public String packageName()
      Description copied from interface: TypeName
      Functions similar to Class.getPackageName().
      Specified by:
      packageName in interface TypeName
      Returns:
      the package name, never null
    • className

      public String className()
      Description copied from interface: TypeName
      Functions similar to Class.getSimpleName().
      Specified by:
      className in interface TypeName
      Returns:
      the simple class name
    • enclosingNames

      public List<String> enclosingNames()
      Description copied from interface: TypeName
      Simple names of enclosing classes (if any exist). For example for type io.helidon.example.Type$NestOne$NestTwo, this would return a list of Type, NestOne.
      Specified by:
      enclosingNames in interface TypeName
      Returns:
      enclosing classes simple names
    • primitive

      public boolean primitive()
      Description copied from interface: TypeName
      Functions similar to Class.isPrimitive().
      Specified by:
      primitive in interface TypeName
      Returns:
      true if this type represents a primitive type
    • array

      public boolean array()
      Description copied from interface: TypeName
      Functions similar to Class.isArray().
      Specified by:
      array in interface TypeName
      Returns:
      true if this type represents a primitive array []
    • generic

      public boolean generic()
      Description copied from interface: TypeName
      Indicates whether this type is using generics.
      Specified by:
      generic in interface TypeName
      Returns:
      used to represent a generic (e.g., "Optional<CB>")
    • wildcard

      public boolean wildcard()
      Description copied from interface: TypeName
      Indicates whether this type is using wildcard generics.
      Specified by:
      wildcard in interface TypeName
      Returns:
      used to represent a wildcard (e.g., "? extends SomeType")
    • typeArguments

      public List<TypeName> typeArguments()
      Description copied from interface: TypeName
      Returns the list of generic type arguments, or an empty list if no generics are in use.
      Specified by:
      typeArguments in interface TypeName
      Returns:
      the type arguments of this type, if this type supports generics/parameterized type
      See Also:
    • typeParameters

      public List<String> typeParameters()
      Description copied from interface: TypeName
      Type parameters associated with the type arguments. The type argument list may be empty, even if this list is not, for example in declaration of the top level type (as arguments are a function of usage of the type). if TypeName.typeArguments() exist, this list MUST exist and have the same size and order (it maps the name to the type).
      Specified by:
      typeParameters in interface TypeName
      Returns:
      type parameter names as declared on this type, or names that represent the TypeName.typeArguments()
    • lowerBounds

      public List<TypeName> lowerBounds()
      Description copied from interface: TypeName
      Generic types that provide keyword extends will have a lower bound defined. Each lower bound may be a real type, or another generic type.

      This list may only have value if this is a generic type.

      Specified by:
      lowerBounds in interface TypeName
      Returns:
      list of lower bounds of this type
      See Also:
    • upperBounds

      public List<TypeName> upperBounds()
      Description copied from interface: TypeName
      Generic types that provide keyword super will have an upper bound defined. Upper bound may be a real type, or another generic type.

      This list may only have value if this is a generic type.

      Specified by:
      upperBounds in interface TypeName
      Returns:
      list of upper bounds of this type
      See Also:
    • componentType

      public Optional<TypeName> componentType()
      Description copied from interface: TypeName
      Component type of array.
      Specified by:
      componentType in interface TypeName
      Returns:
      component type of array
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(TypeName o)
      Description copied from interface: TypeName
      Compare with another type name. First compares by TypeName.name(), than by TypeName.primitive(), and finally by TypeName.array().
      Specified by:
      compareTo in interface Comparable<TypeName>
      Specified by:
      compareTo in interface TypeName
      Parameters:
      o - type name to compare to
      Returns:
      comparison result
      See Also:
    • vararg

      public boolean vararg()
      Description copied from interface: TypeName
      If this is a representation of TypeName.array(), this method can identify that it was declared as a vararg. This may be used for method/constructor parameters (which is the only place this is supported in Java).
      Specified by:
      vararg in interface TypeName
      Returns:
      whether an array is declared as a vararg
    • annotations

      public List<Annotation> annotations()
      Description copied from interface: Annotated
      List of declared and known annotations for this element. Note that "known" implies that the annotation is visible, which depends upon the context in which it was build (such as the of the annotation).
      Specified by:
      annotations in interface Annotated
      Returns:
      the list of annotations declared on this element
    • inheritedAnnotations

      public List<Annotation> inheritedAnnotations()
      Description copied from interface: Annotated
      List of all inherited annotations for this element. Inherited annotations are annotations declared on annotations of this element that are also marked as Inherited.

      The returned list does not contain Annotated.annotations(). If a meta-annotation is present on multiple annotations, it will be returned once for each such declaration.

      This method does not return annotations on super types or interfaces!

      Specified by:
      inheritedAnnotations in interface Annotated
      Returns:
      list of all meta annotations of this element