Interface TypeReferenceProvider

All Known Subinterfaces:
TransformationContext, ValidationContext

@Beta public interface TypeReferenceProvider
Provides and creates TypeReference instances.
Author:
Sven Efftinge
  • Method Details

    • newArrayTypeReference

      TypeReference newArrayTypeReference(TypeReference componentType)
      Creates a new array type reference using the given component type. If the component type is itself an array this method adds a dimension.
      Parameters:
      componentType - the component type of the array type reference
      Returns:
      an array type reference
    • newTypeReference

      TypeReference newTypeReference(String typeName, TypeReference... typeArguments)
      Creates a new type reference for the given name and the given type arguments.
      Parameters:
      typeName - the name of the type to point to
      typeArguments - the type arguments
      Returns:
      a TypeReference pointing to the type with given name, or null if no such type could be found.
    • newTypeReference

      TypeReference newTypeReference(Type typeDeclaration, TypeReference... typeArguments)
      Creates a new type reference for the given typeDeclaration and the type arguments.
      Parameters:
      typeDeclaration - the type to point to
      typeArguments - the type arguments
      Returns:
      a TypeReference pointing to the given type.
    • newSelfTypeReference

      TypeReference newSelfTypeReference(Type typeDeclaration)
      Returns a new self type reference for the given typeDeclaration, e.g. if you have a class like
        class Foo<T> {}
       
      And you want to add a method that returns the instance itself, you would use the self type as the method's return type.
       class Foo<T> {
        def Foo<T> mySelf() {
         this
        }
       }
       
      In contrast, newTypeReference(Type, TypeReference...) without any arguments would return the raw type only and would result in code with warnings:
       class Foo<T> {
        def Foo mySelf() {
         this
        }
       }
       
      Parameters:
      typeDeclaration - the raw type for the newly produced reference
      Returns:
      a reference to the given type declaration
      Since:
      2.7
    • newTypeReference

      TypeReference newTypeReference(Class<?> clazz, TypeReference... typeArguments)
      Creates a new type reference for the given Class and the type arguments.
      Parameters:
      clazz - the clazz to point to
      typeArguments - the type arguments
      Returns:
      a TypeReference pointing to the given type or null if the type is not on the class path of the compiled project.
    • newWildcardTypeReference

      TypeReference newWildcardTypeReference()
      Returns:
      a wildcard type references with upperBound Object
    • newWildcardTypeReference

      TypeReference newWildcardTypeReference(TypeReference upperBound)
      Parameters:
      upperBound - the upper bound of the wildcard type
      Returns:
      a wildcard type references with the given upperBound.
    • newWildcardTypeReferenceWithLowerBound

      TypeReference newWildcardTypeReferenceWithLowerBound(TypeReference lowerBound)
      Parameters:
      lowerBound - the lower bound of the wildcard type
      Returns:
      a wildcard type references with the given lowerBound.
    • getObject

      TypeReference getObject()
      Returns:
      a type reference pointing to Object
    • getString

      TypeReference getString()
      Returns:
      a type reference pointing to String
    • getList

      TypeReference getList(TypeReference param)
      Parameters:
      param - the type argument for the type reference
      Returns:
      a type reference for List with the given type argument.
    • getSet

      Parameters:
      param - the type argument for the type reference
      Returns:
      a type reference for Set with the given type argument.
    • getAnyType

      TypeReference getAnyType()
      The any type is the type of the null pointer and has no concrete representation in Java. It is assignable to every reference type.
      Returns:
      a type reference representing the "any type".
    • getPrimitiveVoid

      TypeReference getPrimitiveVoid()
      Returns:
      a type reference representing 'void'
    • getPrimitiveBoolean

      TypeReference getPrimitiveBoolean()
      Returns:
      a type reference representing 'boolean'
    • getPrimitiveShort

      TypeReference getPrimitiveShort()
      Returns:
      a type reference representing 'short'
    • getPrimitiveInt

      TypeReference getPrimitiveInt()
      Returns:
      a type reference representing 'int'
    • getPrimitiveLong

      TypeReference getPrimitiveLong()
      Returns:
      a type reference representing 'long'
    • getPrimitiveFloat

      TypeReference getPrimitiveFloat()
      Returns:
      a type reference representing 'float'
    • getPrimitiveDouble

      TypeReference getPrimitiveDouble()
      Returns:
      a type reference representing 'double'
    • getPrimitiveChar

      TypeReference getPrimitiveChar()
      Returns:
      a type reference representing 'char'
    • getPrimitiveByte

      TypeReference getPrimitiveByte()
      Returns:
      a type reference representing 'byte'