@Beta
public interface TypeReferenceProvider
TypeReference instances.TypeReference newArrayTypeReference(TypeReference componentType)
componentType - the component type of the array type referenceTypeReference newTypeReference(java.lang.String typeName, TypeReference... typeArguments)
typeName - the name of the type to point totypeArguments - the type argumentsTypeReference pointing to the type with given name, or null if no such type could be found.TypeReference newTypeReference(Type typeDeclaration, TypeReference... typeArguments)
typeDeclaration - the type to point totypeArguments - the type argumentsTypeReference pointing to the given type.TypeReference newSelfTypeReference(Type typeDeclaration)
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
}
}
typeDeclaration - the raw type for the newly produced referenceTypeReference newTypeReference(java.lang.Class<?> clazz, TypeReference... typeArguments)
Class and the type arguments.clazz - the clazz to point totypeArguments - the type argumentsTypeReference pointing to the given type or null if the type is not on the class path of the compiled project.TypeReference newWildcardTypeReference()
ObjectTypeReference newWildcardTypeReference(TypeReference upperBound)
upperBound - the upper bound of the wildcard typeTypeReference newWildcardTypeReferenceWithLowerBound(TypeReference lowerBound)
lowerBound - the lower bound of the wildcard typeTypeReference getObject()
ObjectTypeReference getString()
StringTypeReference getList(TypeReference param)
param - the type argument for the type referenceList with the given type argument.TypeReference getSet(TypeReference param)
param - the type argument for the type referenceSet with the given type argument.TypeReference getAnyType()
TypeReference getPrimitiveVoid()
TypeReference getPrimitiveBoolean()
TypeReference getPrimitiveShort()
TypeReference getPrimitiveInt()
TypeReference getPrimitiveLong()
TypeReference getPrimitiveFloat()
TypeReference getPrimitiveDouble()
TypeReference getPrimitiveChar()
TypeReference getPrimitiveByte()