Module org.eclipse.xtend.lib.macro
Interface TypeReferenceProvider
- All Known Subinterfaces:
TransformationContext,ValidationContext
@Beta
public interface TypeReferenceProvider
Provides and creates
TypeReference instances.- Author:
- Sven Efftinge
-
Method Summary
Modifier and TypeMethodDescriptionThe any type is the type of the null pointer and has no concrete representation in Java.getList(TypeReference param) getSet(TypeReference param) newArrayTypeReference(TypeReference componentType) Creates a new array type reference using the given component type.newSelfTypeReference(Type typeDeclaration) Returns a new self type reference for the given typeDeclaration, e.g.newTypeReference(Class<?> clazz, TypeReference... typeArguments) Creates a new type reference for the givenClassand the type arguments.newTypeReference(String typeName, TypeReference... typeArguments) Creates a new type reference for the given name and the given type arguments.newTypeReference(Type typeDeclaration, TypeReference... typeArguments) Creates a new type reference for the given typeDeclaration and the type arguments.newWildcardTypeReference(TypeReference upperBound) newWildcardTypeReferenceWithLowerBound(TypeReference lowerBound)
-
Method Details
-
newArrayTypeReference
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
Creates a new type reference for the given name and the given type arguments.- Parameters:
typeName- the name of the type to point totypeArguments- the type arguments- Returns:
- a
TypeReferencepointing to the type with given name, ornullif no such type could be found.
-
newTypeReference
Creates a new type reference for the given typeDeclaration and the type arguments.- Parameters:
typeDeclaration- the type to point totypeArguments- the type arguments- Returns:
- a
TypeReferencepointing to the given type.
-
newSelfTypeReference
Returns a new self type reference for the given typeDeclaration, e.g. if you have a class likeclass 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
Creates a new type reference for the givenClassand the type arguments.- Parameters:
clazz- the clazz to point totypeArguments- the type arguments- Returns:
- a
TypeReferencepointing to the given type ornullif the type is not on the class path of the compiled project.
-
newWildcardTypeReference
TypeReference newWildcardTypeReference()- Returns:
- a wildcard type references with upperBound
Object
-
newWildcardTypeReference
- Parameters:
upperBound- the upper bound of the wildcard type- Returns:
- a wildcard type references with the given upperBound.
-
newWildcardTypeReferenceWithLowerBound
- 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
- Parameters:
param- the type argument for the type reference- Returns:
- a type reference for
Listwith the given type argument.
-
getSet
- Parameters:
param- the type argument for the type reference- Returns:
- a type reference for
Setwith 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'
-