Top Description Methods
org.eclipse.xtend.lib.macro.services

public Interface TypeReferenceProvider

Known Direct Subinterfaces
org.eclipse.xtend.lib.macro.TransformationContext, org.eclipse.xtend.lib.macro.ValidationContext
Annotations
@Beta
Imports
java.util.List, .Set, org.eclipse.xtend.lib.macro.declaration.Type, .TypeReference, com.google.common.annotations.Beta

Provides and creates TypeReference instances.
Author
Sven Efftinge

Method Summary

Modifier and TypeMethod and Description
public TypeReference

Returns:

a type reference representing the "any type".
getAnyType
()

The any type is the type of the null pointer and has no concrete representation in Java.

public TypeReference

Returns:

a type reference for List with the given type argument.
getList
(TypeReference
the type argument for the type reference
param
)

public TypeReference

Returns:

a type reference pointing to Object
getObject
()

public TypeReference

Returns:

a type reference representing 'boolean'
getPrimitiveBoolean
()

public TypeReference

Returns:

a type reference representing 'byte'
getPrimitiveByte
()

public TypeReference

Returns:

a type reference representing 'char'
getPrimitiveChar
()

public TypeReference

Returns:

a type reference representing 'double'
getPrimitiveDouble
()

public TypeReference

Returns:

a type reference representing 'float'
getPrimitiveFloat
()

public TypeReference

Returns:

a type reference representing 'int'
getPrimitiveInt
()

public TypeReference

Returns:

a type reference representing 'long'
getPrimitiveLong
()

public TypeReference

Returns:

a type reference representing 'short'
getPrimitiveShort
()

public TypeReference

Returns:

a type reference representing 'void'
getPrimitiveVoid
()

public TypeReference

Returns:

a type reference for Set with the given type argument.
getSet
(TypeReference
the type argument for the type reference
param
)

public TypeReference

Returns:

a type reference pointing to String
getString
()

public TypeReference

Returns:

an array type reference
newArrayTypeReference
(TypeReference
the component type of the array type reference
componentType
)

Creates a new array type reference using the given component type.

public TypeReference

Returns:

a reference to the given type declaration
newSelfTypeReference
(Type
the raw type for the newly produced reference
typeDeclaration
)

Returns a new self type reference for the given typeDeclaration, e.g. if you have a class like

 class Foo<T> {}
public TypeReference

Returns:

a TypeReference pointing to the type with given name, or null if no such type could be found.
newTypeReference
(String
the name of the type to point to
typeName
,
TypeReference...
the type arguments
typeArguments
)

Creates a new type reference for the given name and the given type arguments.

public TypeReference

Returns:

a TypeReference pointing to the given type.
newTypeReference
(Type
the type to point to
typeDeclaration
,
TypeReference...
the type arguments
typeArguments
)

Creates a new type reference for the given typeDeclaration and the type arguments.

public TypeReference

Returns:

a TypeReference pointing to the given type or null if the type is not on the class path of the compiled project.
newTypeReference
(Class<?>
the clazz to point to
clazz
,
TypeReference...
the type arguments
typeArguments
)

Creates a new type reference for the given Class and the type arguments.

public TypeReference

Returns:

a wildcard type references with upperBound Object
newWildcardTypeReference
()

public TypeReference

Returns:

a wildcard type references with the given upperBound.
newWildcardTypeReference
(TypeReference
the upper bound of the wildcard type
upperBound
)

public TypeReference

Returns:

a wildcard type references with the given lowerBound.
newWildcardTypeReferenceWithLowerBound
(TypeReference
the lower bound of the wildcard type
lowerBound
)

Method Detail

getAnyTypeback to summary
public 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:TypeReference

a type reference representing the "any type".

getListback to summary
public TypeReference getList(TypeReference param)
Parameters
param:TypeReference

the type argument for the type reference

Returns:TypeReference

a type reference for List with the given type argument.

getObjectback to summary
public TypeReference getObject()
Returns:TypeReference

a type reference pointing to Object

getPrimitiveBooleanback to summary
public TypeReference getPrimitiveBoolean()
Returns:TypeReference

a type reference representing 'boolean'

getPrimitiveByteback to summary
public TypeReference getPrimitiveByte()
Returns:TypeReference

a type reference representing 'byte'

getPrimitiveCharback to summary
public TypeReference getPrimitiveChar()
Returns:TypeReference

a type reference representing 'char'

getPrimitiveDoubleback to summary
public TypeReference getPrimitiveDouble()
Returns:TypeReference

a type reference representing 'double'

getPrimitiveFloatback to summary
public TypeReference getPrimitiveFloat()
Returns:TypeReference

a type reference representing 'float'

getPrimitiveIntback to summary
public TypeReference getPrimitiveInt()
Returns:TypeReference

a type reference representing 'int'

getPrimitiveLongback to summary
public TypeReference getPrimitiveLong()
Returns:TypeReference

a type reference representing 'long'

getPrimitiveShortback to summary
public TypeReference getPrimitiveShort()
Returns:TypeReference

a type reference representing 'short'

getPrimitiveVoidback to summary
public TypeReference getPrimitiveVoid()
Returns:TypeReference

a type reference representing 'void'

getSetback to summary
public TypeReference getSet(TypeReference param)
Parameters
param:TypeReference

the type argument for the type reference

Returns:TypeReference

a type reference for Set with the given type argument.

getStringback to summary
public TypeReference getString()
Returns:TypeReference

a type reference pointing to String

newArrayTypeReferenceback to summary
public 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:TypeReference

the component type of the array type reference

Returns:TypeReference

an array type reference

newSelfTypeReferenceback to summary
public 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:Type

the raw type for the newly produced reference

Returns:TypeReference

a reference to the given type declaration

Since
2.7
newTypeReferenceback to summary
public TypeReference newTypeReference(String typeName, TypeReference... typeArguments)

Creates a new type reference for the given name and the given type arguments.

Parameters
typeName:String

the name of the type to point to

typeArguments:TypeReference[]

the type arguments

Returns:TypeReference

a TypeReference pointing to the type with given name, or null if no such type could be found.

newTypeReferenceback to summary
public TypeReference newTypeReference(Type typeDeclaration, TypeReference... typeArguments)

Creates a new type reference for the given typeDeclaration and the type arguments.

Parameters
typeDeclaration:Type

the type to point to

typeArguments:TypeReference[]

the type arguments

Returns:TypeReference

a TypeReference pointing to the given type.

newTypeReferenceback to summary
public TypeReference newTypeReference(Class<?> clazz, TypeReference... typeArguments)

Creates a new type reference for the given Class and the type arguments.

Parameters
clazz:Class<?>

the clazz to point to

typeArguments:TypeReference[]

the type arguments

Returns:TypeReference

a TypeReference pointing to the given type or null if the type is not on the class path of the compiled project.

newWildcardTypeReferenceback to summary
public TypeReference newWildcardTypeReference()
Returns:TypeReference

a wildcard type references with upperBound Object

newWildcardTypeReferenceback to summary
public TypeReference newWildcardTypeReference(TypeReference upperBound)
Parameters
upperBound:TypeReference

the upper bound of the wildcard type

Returns:TypeReference

a wildcard type references with the given upperBound.

newWildcardTypeReferenceWithLowerBoundback to summary
public TypeReference newWildcardTypeReferenceWithLowerBound(TypeReference lowerBound)
Parameters
lowerBound:TypeReference

the lower bound of the wildcard type

Returns:TypeReference

a wildcard type references with the given lowerBound.