Package spoon.reflect.factory
Class TypeFactory
java.lang.Object
spoon.reflect.factory.SubFactory
spoon.reflect.factory.TypeFactory
- Direct Known Subclasses:
AnnotationFactory
,ClassFactory
,EnumFactory
,InterfaceFactory
The
CtType
sub-factory.-
Field Summary
FieldsModifier and TypeFieldDescriptionFields inherited from class spoon.reflect.factory.SubFactory
factory
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a reference on the boolean primitive type.Returns a reference on the boolean type.Returns a reference on the byte primitive type.byteType()
Returns a reference on the byte type.Returns a reference on the character primitive type.Returns a reference on the character type.<T> CtArrayTypeReference<T>
createArrayReference(String qualifiedName)
Creates a reference to an array of given type.<T> CtArrayTypeReference<T[]>
createArrayReference(CtType<T> type)
Creates a reference to an array of given type.createArrayReference(CtTypeReference<?> reference, int n)
Creates a reference to a n-dimension array of given type.<T> CtArrayTypeReference<T[]>
createArrayReference(CtTypeReference<T> reference)
Creates a reference to a one-dimension array of given type.createImport(CtReference reference)
Creates an import declaration.<T> CtIntersectionTypeReference<T>
createIntersectionTypeReferenceWithBounds(List<CtTypeReference<?>> bounds)
Creates an intersection type reference.<T> CtTypeReference<T>
createReference(Class<T> type)
<T> CtTypeReference<T>
createReference(Class<T> type, boolean includingFormalTypeParameter)
Creates a reference to a simple type<T> CtTypeReference<T>
createReference(String qualifiedName)
Create a reference to a simple type<T> CtTypeReference<T>
createReference(CtType<T> type)
Create a reference to a simple type<T> CtTypeReference<T>
createReference(CtType<T> type, boolean includingFormalTypeParameter)
createReference(CtTypeParameter type)
Create a reference to a simple typeList<CtTypeReference<?>>
createReferences(List<Class<?>> classes)
Creates a collection of type references from a collection of classes.<T> CtTypeReference<T>
createSimplyQualifiedReference(String qualifiedName)
Create a reference to a simple type, setting the beginning of its fully qualified name as implicitcreateTypeAdapter(CtFormalTypeDeclarer formalTypeDeclarer)
Create aGenericTypeAdapter
for adapting of formal type parameters from any compatible context to the context of provided `formalTypeDeclarer`createTypeMemberWildcardImportReference(CtTypeReference typeReference)
Create a wildcard reference to a simple typeCreates a type parameter reference with no bounds.createUnresolvedImport(String reference, boolean isStatic)
dateType()
Returns a reference on the date type.Returns a reference on the double primitive type.Returns a reference on the double type.Returns a reference on the float primitive type.Returns a reference on the float type.<T> CtType<T>
Gets a type from its runtime Java class.<T> CtType<T>
Gets a created type from its qualified name if source in the source classpath.getAll()
Gets the list of all top-level created types.getAll(boolean includeNestedTypes)
Gets the list of all created types.protected String
getDeclaringTypeName(String qualifiedName)
Gets the declaring type name for a given Java qualified name.Returns the default bounding type valueprotected String
getPackageName(String qualifiedName)
Gets the package name for a given Java qualified name.protected String
getSimpleName(String qualifiedName)
Gets the simple name for a given Java qualified name.protected int
hasInnerType(String qualifiedName)
Tells if a given Java qualified name is that of an inner type.protected int
hasPackage(String qualifiedName)
Tells if a given Java qualified name contains a package name.Returns a reference on the integer primitive type.Returns a reference on the integer type.Returns a reference on the long primitive type.longType()
Returns a reference on the long type.nullType()
Returns a reference on the null type (type of null).Returns a reference on the object type.Returns a reference on the short primitive type.Returns a reference on the short type.Returns a reference on the string type.Returns a reference on the void primitive type.voidType()
Returns a reference on the void type.
-
Field Details
-
NULL_TYPE
-
VOID
-
STRING
-
BOOLEAN
-
BYTE
-
CHARACTER
-
INTEGER
-
LONG
-
FLOAT
-
DOUBLE
-
VOID_PRIMITIVE
-
BOOLEAN_PRIMITIVE
-
BYTE_PRIMITIVE
-
CHARACTER_PRIMITIVE
-
INTEGER_PRIMITIVE
-
LONG_PRIMITIVE
-
FLOAT_PRIMITIVE
-
DOUBLE_PRIMITIVE
-
SHORT
-
SHORT_PRIMITIVE
-
DATE
-
OBJECT
-
ITERABLE
-
COLLECTION
-
LIST
-
SET
-
MAP
-
ENUM
-
OMITTED_TYPE_ARG_TYPE
-
-
Constructor Details
-
TypeFactory
Creates a new type sub-factory.- Parameters:
factory
- the parent factory
-
TypeFactory
public TypeFactory()
-
-
Method Details
-
nullType
Returns a reference on the null type (type of null). -
voidType
Returns a reference on the void type. -
voidPrimitiveType
Returns a reference on the void primitive type. -
stringType
Returns a reference on the string type. -
booleanType
Returns a reference on the boolean type. -
booleanPrimitiveType
Returns a reference on the boolean primitive type. -
byteType
Returns a reference on the byte type. -
bytePrimitiveType
Returns a reference on the byte primitive type. -
characterType
Returns a reference on the character type. -
characterPrimitiveType
Returns a reference on the character primitive type. -
integerType
Returns a reference on the integer type. -
integerPrimitiveType
Returns a reference on the integer primitive type. -
longType
Returns a reference on the long type. -
longPrimitiveType
Returns a reference on the long primitive type. -
floatType
Returns a reference on the float type. -
floatPrimitiveType
Returns a reference on the float primitive type. -
doubleType
Returns a reference on the double type. -
doublePrimitiveType
Returns a reference on the double primitive type. -
shortType
Returns a reference on the short type. -
shortPrimitiveType
Returns a reference on the short primitive type. -
dateType
Returns a reference on the date type. -
objectType
Returns a reference on the object type. -
createArrayReference
Creates a reference to an array of given type.- Type Parameters:
T
- type of array- Parameters:
type
- type of array values
-
createArrayReference
Creates a reference to a one-dimension array of given type. -
createArrayReference
Creates a reference to a n-dimension array of given type. -
createArrayReference
Creates a reference to an array of given type. -
createReference
-
createReference
Creates a reference to a simple type -
createReference
Create a reference to a simple type -
createTypeMemberWildcardImportReference
public CtTypeMemberWildcardImportReference createTypeMemberWildcardImportReference(CtTypeReference typeReference)Create a wildcard reference to a simple type -
createReference
public <T> CtTypeReference<T> createReference(CtType<T> type, boolean includingFormalTypeParameter)- Parameters:
includingFormalTypeParameter
- if true then references to formal type parameters are added as actual type arguments of returnedCtTypeReference
-
createReference
Create a reference to a simple type -
createReference
Create a reference to a simple type -
createSimplyQualifiedReference
Create a reference to a simple type, setting the beginning of its fully qualified name as implicit -
get
Gets a created type from its qualified name if source in the source classpath. `TypeFactory#get(String)` returns null if the class is not in the source classpath (even if it is in the binary classpath). `TypeFactory#get(Class)` returns null if the class is neither in the source classpath nor in the binary classpath, and returns a [shadow class](http://spoon.gforge.inria.fr/reflection.html) if it is only in the binary classpath. Note that a shadow class has empty method bodies, if you need a shadow class with method bodies, see [spoon-decompiler](https://github.com/INRIA/spoon/tree/master/spoon-decompiler))- Returns:
- a type if source in the source classpath or null if does not exist
-
getAll
Gets the list of all top-level created types. -
getAll
Gets the list of all created types. -
get
Gets a type from its runtime Java class. If the class isn't in the spoon path, the class will be built from the Java reflection and will be marked as shadow (seeCtShadowable
).- Type Parameters:
T
- actual type of the class- Parameters:
cl
- the java class: note that this class should be Class<T> but it then poses problem when T is a generic type itself
-
getDeclaringTypeName
Gets the declaring type name for a given Java qualified name. -
createReferences
Creates a collection of type references from a collection of classes. -
getPackageName
Gets the package name for a given Java qualified name. -
getSimpleName
Gets the simple name for a given Java qualified name. -
hasInnerType
Tells if a given Java qualified name is that of an inner type. -
hasPackage
Tells if a given Java qualified name contains a package name. -
createTypeParameterReference
Creates a type parameter reference with no bounds.- Parameters:
name
- the name of the formal parameter
-
createTypeAdapter
Create aGenericTypeAdapter
for adapting of formal type parameters from any compatible context to the context of provided `formalTypeDeclarer`- Parameters:
formalTypeDeclarer
- the target scope of the returnedGenericTypeAdapter
-
createIntersectionTypeReferenceWithBounds
public <T> CtIntersectionTypeReference<T> createIntersectionTypeReferenceWithBounds(List<CtTypeReference<?>> bounds)Creates an intersection type reference.- Type Parameters:
T
- Type of the first bound.- Parameters:
bounds
- List of bounds saved in the intersection type. The first bound will be the intersection type.
-
getDefaultBoundingType
Returns the default bounding type value -
createImport
Creates an import declaration. -
createUnresolvedImport
-