Class JavaTypeDefinition
- java.lang.Object
-
- net.sourceforge.pmd.lang.java.typeresolution.typedefinition.JavaTypeDefinition
-
- All Implemented Interfaces:
TypeDefinition
public abstract class JavaTypeDefinition extends java.lang.Object implements TypeDefinition
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedJavaTypeDefinition(TypeDefinitionType definitionType)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleanequals(java.lang.Object obj)static JavaTypeDefinitionforClass(java.lang.Class<?> clazz, JavaTypeDefinition... boundGenerics)static JavaTypeDefinitionforClass(TypeDefinitionType type, java.lang.Class<?> clazz, JavaTypeDefinition... boundGenerics)static JavaTypeDefinitionforClass(TypeDefinitionType type, JavaTypeDefinition... intersectionTypes)abstract JavaTypeDefinitiongetAsSuper(java.lang.Class<?> superClazz)abstract JavaTypeDefinitiongetComponentType()Gets the component type of this type definition if it is an array type.TypeDefinitionTypegetDefinitionType()abstract JavaTypeDefinitiongetElementType()Gets the element type of this type definition if it is an array type.abstract JavaTypeDefinitiongetEnclosingClass()abstract java.util.Set<java.lang.Class<?>>getErasedSuperTypeSet()abstract JavaTypeDefinitiongetGenericType(int index)abstract JavaTypeDefinitiongetGenericType(java.lang.String parameterName)static intgetGenericTypeIndex(java.lang.reflect.TypeVariable<?>[] typeParameters, java.lang.String parameterName)abstract JavaTypeDefinitiongetJavaType(int index)abstract intgetJavaTypeCount()abstract java.util.Set<JavaTypeDefinition>getSuperTypeSet()protected abstract java.util.Set<JavaTypeDefinition>getSuperTypeSet(java.util.Set<JavaTypeDefinition> destinationSet)abstract java.lang.Class<?>getType()Get the raw Class type of the definition.abstract intgetTypeParameterCount()abstract inthashCode()abstract booleanhasSameErasureAs(JavaTypeDefinition def)abstract booleanisArrayType()abstract booleanisClassOrInterface()booleanisExactType()abstract booleanisGeneric()abstract booleanisIntersectionType()booleanisLowerBound()abstract booleanisNullType()abstract booleanisPrimitive()abstract booleanisRawType()Returns true if this type has type parameters and has not been parameterized, e.g.booleanisUpperBound()booleanisWildcard()abstract JavaTypeDefinitionresolveTypeDefinition(java.lang.reflect.Type type)abstract JavaTypeDefinitionresolveTypeDefinition(java.lang.reflect.Type type, java.lang.reflect.Method method, java.util.List<JavaTypeDefinition> methodTypeArgs)protected abstract java.lang.StringshallowString()abstract java.lang.StringtoString()abstract JavaTypeDefinitionwithDimensions(int numDimensions)Returns the type definition of the array type which has the given number of array dimensions, plus the dimensions of this type definition.
-
-
-
Constructor Detail
-
JavaTypeDefinition
protected JavaTypeDefinition(TypeDefinitionType definitionType)
-
-
Method Detail
-
forClass
public static JavaTypeDefinition forClass(TypeDefinitionType type, java.lang.Class<?> clazz, JavaTypeDefinition... boundGenerics)
-
forClass
public static JavaTypeDefinition forClass(TypeDefinitionType type, JavaTypeDefinition... intersectionTypes)
-
forClass
public static JavaTypeDefinition forClass(java.lang.Class<?> clazz, JavaTypeDefinition... boundGenerics)
-
getType
public abstract java.lang.Class<?> getType()
Description copied from interface:TypeDefinitionGet the raw Class type of the definition.- Specified by:
getTypein interfaceTypeDefinition- Returns:
- Raw Class type.
-
getEnclosingClass
public abstract JavaTypeDefinition getEnclosingClass()
-
isGeneric
public abstract boolean isGeneric()
-
getGenericTypeIndex
public static int getGenericTypeIndex(java.lang.reflect.TypeVariable<?>[] typeParameters, java.lang.String parameterName)
-
getGenericType
public abstract JavaTypeDefinition getGenericType(java.lang.String parameterName)
-
getGenericType
public abstract JavaTypeDefinition getGenericType(int index)
-
resolveTypeDefinition
public abstract JavaTypeDefinition resolveTypeDefinition(java.lang.reflect.Type type)
-
resolveTypeDefinition
public abstract JavaTypeDefinition resolveTypeDefinition(java.lang.reflect.Type type, java.lang.reflect.Method method, java.util.List<JavaTypeDefinition> methodTypeArgs)
-
isClassOrInterface
public abstract boolean isClassOrInterface()
-
isNullType
public abstract boolean isNullType()
-
isPrimitive
public abstract boolean isPrimitive()
-
hasSameErasureAs
public abstract boolean hasSameErasureAs(JavaTypeDefinition def)
-
getTypeParameterCount
public abstract int getTypeParameterCount()
-
isArrayType
public abstract boolean isArrayType()
-
getComponentType
public abstract JavaTypeDefinition getComponentType()
Gets the component type of this type definition if it is an array type. The component type of an array is the type is the same type as the array, with one less dimension, e.g. the component type ofint[][][]isint[][].- Returns:
- The component type of this array type
- Throws:
java.lang.IllegalStateException- if this definition doesn't identify an array type- See Also:
getElementType()
-
getElementType
public abstract JavaTypeDefinition getElementType()
Gets the element type of this type definition if it is an array type. The component type of an array is the type is the same type as the array, stripped of all array dimensions, e.g. the element type ofint[][][]isint.- Returns:
- The element type of this array type, or this
type definition if
isArrayType()returns false - See Also:
getComponentType()
-
withDimensions
public abstract JavaTypeDefinition withDimensions(int numDimensions)
Returns the type definition of the array type which has the given number of array dimensions, plus the dimensions of this type definition. Examples, assuming JavaTypeDefinition and Class are interchangeable (== is equality, not identity):int.class.withDimensions(3) == int[][][].classint[].class.withDimensions(1) == int[][].classc.withDimensions(0) == cn > 0 => c.withDimensions(n).getComponentType() == c.withDimensions(n - 1)
- Parameters:
numDimensions- Number of dimensions added to this type in the resulting array type- Returns:
- A new type definition, or this if numDimensions == 0
- Throws:
java.lang.IllegalArgumentException- if numDimensions < 0
-
toString
public abstract java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public abstract boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public abstract int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getSuperTypeSet
public abstract java.util.Set<JavaTypeDefinition> getSuperTypeSet()
-
getSuperTypeSet
protected abstract java.util.Set<JavaTypeDefinition> getSuperTypeSet(java.util.Set<JavaTypeDefinition> destinationSet)
-
getErasedSuperTypeSet
public abstract java.util.Set<java.lang.Class<?>> getErasedSuperTypeSet()
-
isRawType
public abstract boolean isRawType()
Returns true if this type has type parameters and has not been parameterized, e.g.Listinstead ofList<T>.
-
getAsSuper
public abstract JavaTypeDefinition getAsSuper(java.lang.Class<?> superClazz)
-
isExactType
public final boolean isExactType()
-
isUpperBound
public final boolean isUpperBound()
-
isLowerBound
public final boolean isLowerBound()
-
isIntersectionType
public abstract boolean isIntersectionType()
-
isWildcard
public final boolean isWildcard()
-
getDefinitionType
public final TypeDefinitionType getDefinitionType()
-
getJavaType
public abstract JavaTypeDefinition getJavaType(int index)
-
getJavaTypeCount
public abstract int getJavaTypeCount()
-
shallowString
protected abstract java.lang.String shallowString()
-
-