Class ResolvedReferenceType
java.lang.Object
com.github.javaparser.resolution.types.ResolvedReferenceType
- All Implemented Interfaces:
ResolvedTypeParameterValueProvider
,ResolvedTypeParametrized
,ResolvedType
public abstract class ResolvedReferenceType
extends Object
implements ResolvedType, ResolvedTypeParametrized, ResolvedTypeParameterValueProvider
A ReferenceType like a class, an interface or an enum. Note that this type can contain also the values
specified for the type parameters.
- Author:
- Federico Tomassetti
-
Field Summary
Modifier and TypeFieldDescriptionprotected static String
protected static String
protected ResolvedReferenceTypeDeclaration
protected ResolvedTypeParametersMap
-
Constructor Summary
ConstructorDescriptionResolvedReferenceType(ResolvedReferenceTypeDeclaration typeDeclaration)
ResolvedReferenceType(ResolvedReferenceTypeDeclaration typeDeclaration, List<ResolvedType> typeArguments)
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
protected abstract ResolvedReferenceType
create(ResolvedReferenceTypeDeclaration typeDeclaration)
protected ResolvedReferenceType
create(ResolvedReferenceTypeDeclaration typeDeclaration, ResolvedTypeParametersMap typeParametersMap)
protected abstract ResolvedReferenceType
create(ResolvedReferenceTypeDeclaration typeDeclaration, List<ResolvedType> typeParameters)
abstract ResolvedReferenceType
deriveTypeParameters(ResolvedTypeParametersMap typeParametersMap)
describe()
boolean
erasure()
abstract List<ResolvedReferenceType>
Return all ancestors, that means all superclasses and interfaces.Fields which are visible to inheritors.Get a list of all the methods available on this type.abstract Set<ResolvedFieldDeclaration>
Fields declared on this type.abstract Set<MethodUsage>
Methods declared on this type.abstract List<ResolvedReferenceType>
Return direct ancestors, that means the superclasses and interfaces implemented directly.getFieldType(String name)
The type of the field could be different from the one in the corresponding FieldDeclaration because type variables would be solved.getGenericParameterByName(String name)
Get the type associated with the type parameter with the given name.getId()
Id of the declaration.Qualified name of the declaration.Corresponding TypeDeclarationGet the values for all type parameters declared on this type.int
hashCode()
boolean
hasName()
Has the TypeDeclaration a name? Anonymous classes do not have one.abstract boolean
isAssignableBy(ResolvedType other)
This method checks if ThisType t = new OtherType() would compile.protected boolean
isCorrespondingBoxingType(String typeName)
boolean
boolean
We don't make this _ex_plicit in the data representation because that would affect codegen and make everything generate like<T extends Object>
instead of<T>
boolean
boolean
Can this be seen as a ReferenceTypeUsage? In other words: is this a reference to a class, an interface or an enum?boolean
boolean
isUnboxableTo(ResolvedPrimitiveType primitiveType)
replaceTypeVariables(ResolvedTypeParameterDeclaration tpToReplace, ResolvedType replaced, Map<ResolvedTypeParameterDeclaration,ResolvedType> inferredTypes)
Replace all variables referring to the given TypeParameter with the given value.abstract ResolvedType
toString()
abstract ResolvedType
transformTypeParameters(ResolvedTypeTransformer transformer)
Execute a transformation on all the type parameters of this element.Get the values for all type parameters declared on this type.typeParamValue(ResolvedTypeParameterDeclaration typeParameterDeclaration)
Calculate the value for the given type parameter.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.github.javaparser.resolution.types.ResolvedType
arrayLevel, asArrayType, asConstraintType, asPrimitive, asTypeParameter, asTypeVariable, asUnionType, asWildcard, isArray, isConstraint, isInferenceVariable, isNull, isNumericType, isPrimitive, isReference, isTypeVariable, isUnionType, isVoid, isWildcard, mention, replaceTypeVariables
Methods inherited from interface com.github.javaparser.resolution.types.parametrization.ResolvedTypeParameterValueProvider
useThisTypeParametersOnTheGivenType
-
Field Details
-
JAVA_LANG_ENUM
-
JAVA_LANG_OBJECT
-
typeDeclaration
-
typeParametersMap
-
-
Constructor Details
-
ResolvedReferenceType
-
ResolvedReferenceType
public ResolvedReferenceType(ResolvedReferenceTypeDeclaration typeDeclaration, List<ResolvedType> typeArguments)
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
toString
-
isReferenceType
public final boolean isReferenceType()Description copied from interface:ResolvedType
Can this be seen as a ReferenceTypeUsage? In other words: is this a reference to a class, an interface or an enum?- Specified by:
isReferenceType
in interfaceResolvedType
-
asReferenceType
- Specified by:
asReferenceType
in interfaceResolvedType
-
describe
- Specified by:
describe
in interfaceResolvedType
-
transformTypeParameters
Execute a transformation on all the type parameters of this element. -
replaceTypeVariables
public ResolvedType replaceTypeVariables(ResolvedTypeParameterDeclaration tpToReplace, ResolvedType replaced, Map<ResolvedTypeParameterDeclaration,ResolvedType> inferredTypes)Description copied from interface:ResolvedType
Replace all variables referring to the given TypeParameter with the given value. By replacing these values I could also infer some type equivalence. Those would be collected in the given map.- Specified by:
replaceTypeVariables
in interfaceResolvedType
-
isAssignableBy
This method checks if ThisType t = new OtherType() would compile.- Specified by:
isAssignableBy
in interfaceResolvedType
-
getAllAncestors
Return all ancestors, that means all superclasses and interfaces. This list should always include Object (unless this is a reference to Object). The type typeParametersValues should be expressed in terms of this type typeParametersValues.For example, given:
class Foo<A, B> {} class Bar<C> extends Foo<C, String> {}
a call to getAllAncestors on a reference to Bar having type parameter Boolean should include Foo<Boolean, String>.
-
getDirectAncestors
Return direct ancestors, that means the superclasses and interfaces implemented directly. This list should include Object if the class has no other superclass or the interface is not extending another interface. There is an exception for Object itself. -
getAllInterfacesAncestors
-
getAllClassesAncestors
-
getGenericParameterByName
Get the type associated with the type parameter with the given name. It returns Optional.empty unless the type declaration declares a type parameter with the given name.- Specified by:
getGenericParameterByName
in interfaceResolvedTypeParameterValueProvider
-
typeParametersValues
Get the values for all type parameters declared on this type. The list can be empty for raw types. -
getTypeParametersMap
Get the values for all type parameters declared on this type. In case of raw types the values correspond to TypeVariables. -
typeParametersMap
- Specified by:
typeParametersMap
in interfaceResolvedTypeParametrized
-
getTypeDeclaration
Corresponding TypeDeclaration -
getFieldType
The type of the field could be different from the one in the corresponding FieldDeclaration because type variables would be solved. -
hasName
public boolean hasName()Has the TypeDeclaration a name? Anonymous classes do not have one. -
getQualifiedName
Qualified name of the declaration. -
getId
Id of the declaration. It corresponds to the qualified name, unless for local classes. -
getDeclaredMethods
Methods declared on this type. -
getDeclaredFields
Fields declared on this type. -
isRawType
public boolean isRawType() -
typeParamValue
public Optional<ResolvedType> typeParamValue(ResolvedTypeParameterDeclaration typeParameterDeclaration)Description copied from interface:ResolvedTypeParameterValueProvider
Calculate the value for the given type parameter. It could be inherited.- Specified by:
typeParamValue
in interfaceResolvedTypeParameterValueProvider
-
toRawType
-
getAllMethods
Get a list of all the methods available on this type. This list includes methods declared in this type and methods inherited. This list includes methods of all sort of visibility. However it does not include methods that have been overwritten. -
getAllFieldsVisibleToInheritors
Fields which are visible to inheritors. They include all inherited fields which are visible to this type plus all declared fields which are not private. -
getAllMethodsVisibleToInheritors
-
create
protected abstract ResolvedReferenceType create(ResolvedReferenceTypeDeclaration typeDeclaration, List<ResolvedType> typeParameters) -
create
protected ResolvedReferenceType create(ResolvedReferenceTypeDeclaration typeDeclaration, ResolvedTypeParametersMap typeParametersMap) -
create
-
isCorrespondingBoxingType
-
compareConsideringTypeParameters
-
deriveTypeParameters
public abstract ResolvedReferenceType deriveTypeParameters(ResolvedTypeParametersMap typeParametersMap) -
isJavaLangObject
public boolean isJavaLangObject()We don't make this _ex_plicit in the data representation because that would affect codegen and make everything generate like<T extends Object>
instead of<T>
- Returns:
- true, if this represents
java.lang.Object
- See Also:
ResolvedReferenceTypeDeclaration.isJavaLangObject()
, https://github.com/javaparser/javaparser/issues/2044
-
isJavaLangEnum
public boolean isJavaLangEnum()- Returns:
- true, if this represents
java.lang.Enum
- See Also:
ResolvedReferenceTypeDeclaration.isJavaLangEnum()
-
isUnboxable
public boolean isUnboxable() -
isUnboxableTo
-
toUnboxedType
-
erasure
- Specified by:
erasure
in interfaceResolvedType
-