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 TypeFieldDescriptionfinal CtTypeReference<Boolean>Deprecated, for removal: This API element is subject to removal in a future version.final CtTypeReference<Boolean>Deprecated, for removal: This API element is subject to removal in a future version.UsebooleanPrimitiveType()instead.final CtTypeReference<Byte>Deprecated, for removal: This API element is subject to removal in a future version.UsebyteType()instead.final CtTypeReference<Byte>Deprecated, for removal: This API element is subject to removal in a future version.UsebytePrimitiveType()instead.final CtTypeReference<Character>Deprecated, for removal: This API element is subject to removal in a future version.UsecharacterType()instead.final CtTypeReference<Character>Deprecated, for removal: This API element is subject to removal in a future version.UsecharacterPrimitiveType()instead.final CtTypeReference<Collection>Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(Collection.class)instead.final CtTypeReference<Date>Deprecated, for removal: This API element is subject to removal in a future version.UsedateType()instead.final CtTypeReference<Double>Deprecated, for removal: This API element is subject to removal in a future version.UsedoubleType()instead.final CtTypeReference<Double>Deprecated, for removal: This API element is subject to removal in a future version.UsedoublePrimitiveType()instead.final CtTypeReference<Enum>Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(Enum.class)instead.final CtTypeReference<Float>Deprecated, for removal: This API element is subject to removal in a future version.UsefloatType()instead.final CtTypeReference<Float>Deprecated, for removal: This API element is subject to removal in a future version.UsefloatPrimitiveType()instead.final CtTypeReference<Integer>Deprecated, for removal: This API element is subject to removal in a future version.UseintegerType()instead.final CtTypeReference<Integer>Deprecated, for removal: This API element is subject to removal in a future version.UseintegerPrimitiveType()instead.final CtTypeReference<Iterable>Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(Iterable.class)instead.final CtTypeReference<List>Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(List.class)instead.final CtTypeReference<Long>Deprecated, for removal: This API element is subject to removal in a future version.UselongType()instead.final CtTypeReference<Long>Deprecated, for removal: This API element is subject to removal in a future version.UselongPrimitiveType()instead.final CtTypeReference<Map>Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(Map.class)instead.final CtTypeReference<?>Deprecated, for removal: This API element is subject to removal in a future version.UsenullType()instead.final CtTypeReference<Object>Deprecated, for removal: This API element is subject to removal in a future version.UseobjectType()instead.final CtTypeReference<?>Deprecated, for removal: This API element is subject to removal in a future version.Deprecated for removal without replacement.final CtTypeReference<Set>Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(Set.class)instead.final CtTypeReference<Short>Deprecated, for removal: This API element is subject to removal in a future version.UseshortType()instead.final CtTypeReference<Short>Deprecated, for removal: This API element is subject to removal in a future version.UseshortPrimitiveType()instead.final CtTypeReference<String>Deprecated, for removal: This API element is subject to removal in a future version.UsestringType()instead.final CtTypeReference<Void>Deprecated, for removal: This API element is subject to removal in a future version.UsevoidType()instead.final CtTypeReference<Void>Deprecated, for removal: This API element is subject to removal in a future version.UsevoidPrimitiveType()instead.Fields 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>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) 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 aGenericTypeAdapterfor 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 StringgetDeclaringTypeName(String qualifiedName) Gets the declaring type name for a given Java qualified name.Returns the default bounding type valueprotected StringgetPackageName(String qualifiedName) Gets the package name for a given Java qualified name.protected StringgetSimpleName(String qualifiedName) Gets the simple name for a given Java qualified name.protected inthasInnerType(String qualifiedName) Tells if a given Java qualified name is that of an inner type.protected inthasPackage(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
Deprecated, for removal: This API element is subject to removal in a future version.UsenullType()instead. -
VOID
Deprecated, for removal: This API element is subject to removal in a future version.UsevoidType()instead. -
STRING
Deprecated, for removal: This API element is subject to removal in a future version.UsestringType()instead. -
BOOLEAN
Deprecated, for removal: This API element is subject to removal in a future version.UsebooleanType()instead. -
BYTE
Deprecated, for removal: This API element is subject to removal in a future version.UsebyteType()instead. -
CHARACTER
Deprecated, for removal: This API element is subject to removal in a future version.UsecharacterType()instead. -
INTEGER
Deprecated, for removal: This API element is subject to removal in a future version.UseintegerType()instead. -
LONG
Deprecated, for removal: This API element is subject to removal in a future version.UselongType()instead. -
FLOAT
Deprecated, for removal: This API element is subject to removal in a future version.UsefloatType()instead. -
DOUBLE
Deprecated, for removal: This API element is subject to removal in a future version.UsedoubleType()instead. -
VOID_PRIMITIVE
Deprecated, for removal: This API element is subject to removal in a future version.UsevoidPrimitiveType()instead. -
BOOLEAN_PRIMITIVE
@Deprecated(since="11.0.0", forRemoval=true) public final CtTypeReference<Boolean> BOOLEAN_PRIMITIVEDeprecated, for removal: This API element is subject to removal in a future version.UsebooleanPrimitiveType()instead. -
BYTE_PRIMITIVE
Deprecated, for removal: This API element is subject to removal in a future version.UsebytePrimitiveType()instead. -
CHARACTER_PRIMITIVE
@Deprecated(since="11.0.0", forRemoval=true) public final CtTypeReference<Character> CHARACTER_PRIMITIVEDeprecated, for removal: This API element is subject to removal in a future version.UsecharacterPrimitiveType()instead. -
INTEGER_PRIMITIVE
@Deprecated(since="11.0.0", forRemoval=true) public final CtTypeReference<Integer> INTEGER_PRIMITIVEDeprecated, for removal: This API element is subject to removal in a future version.UseintegerPrimitiveType()instead. -
LONG_PRIMITIVE
Deprecated, for removal: This API element is subject to removal in a future version.UselongPrimitiveType()instead. -
FLOAT_PRIMITIVE
Deprecated, for removal: This API element is subject to removal in a future version.UsefloatPrimitiveType()instead. -
DOUBLE_PRIMITIVE
Deprecated, for removal: This API element is subject to removal in a future version.UsedoublePrimitiveType()instead. -
SHORT
Deprecated, for removal: This API element is subject to removal in a future version.UseshortType()instead. -
SHORT_PRIMITIVE
Deprecated, for removal: This API element is subject to removal in a future version.UseshortPrimitiveType()instead. -
DATE
Deprecated, for removal: This API element is subject to removal in a future version.UsedateType()instead. -
OBJECT
Deprecated, for removal: This API element is subject to removal in a future version.UseobjectType()instead. -
ITERABLE
Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(Iterable.class)instead. -
COLLECTION
Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(Collection.class)instead. -
LIST
Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(List.class)instead. -
SET
Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(Set.class)instead. -
MAP
Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(Map.class)instead. -
ENUM
Deprecated, for removal: This API element is subject to removal in a future version.UseTypeFactory#createReference(Enum.class)instead. -
OMITTED_TYPE_ARG_TYPE
Deprecated, for removal: This API element is subject to removal in a future version.Deprecated for removal without replacement.
-
-
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
- 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 aGenericTypeAdapterfor 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
-
booleanType()instead.