public abstract class ReferenceType extends java.lang.Object implements Type, TypeParametrized, TypeParameterValueProvider
Modifier and Type | Field and Description |
---|---|
protected ReferenceTypeDeclaration |
typeDeclaration |
protected TypeParametersMap |
typeParametersMap |
protected TypeSolver |
typeSolver |
Constructor and Description |
---|
ReferenceType(ReferenceTypeDeclaration typeDeclaration,
java.util.List<Type> typeParameters,
TypeSolver typeSolver) |
ReferenceType(ReferenceTypeDeclaration typeDeclaration,
TypeSolver typeSolver) |
Modifier and Type | Method and Description |
---|---|
ReferenceType |
asReferenceType() |
protected boolean |
compareConsideringTypeParameters(ReferenceType other) |
protected abstract ReferenceType |
create(ReferenceTypeDeclaration typeDeclaration,
java.util.List<Type> typeParameters,
TypeSolver typeSolver) |
protected ReferenceType |
create(ReferenceTypeDeclaration typeDeclaration,
TypeParametersMap typeParametersMap,
TypeSolver typeSolver) |
protected abstract ReferenceType |
create(ReferenceTypeDeclaration typeDeclaration,
TypeSolver typeSolver) |
ReferenceType |
deriveTypeParameters(TypeParametersMap typeParametersMap) |
java.lang.String |
describe() |
boolean |
equals(java.lang.Object o) |
java.util.List<ReferenceType> |
getAllAncestors()
Return all ancestors, that means all superclasses and interfaces.
|
java.util.List<ReferenceType> |
getAllClassesAncestors() |
java.util.List<ReferenceType> |
getAllInterfacesAncestors() |
abstract java.util.Set<MethodUsage> |
getDeclaredMethods()
Methods declared on this type.
|
java.util.Optional<Type> |
getFieldType(java.lang.String name)
The type of the field could be different from the one in the corresponding FieldDeclaration because
type variables would be solved.
|
java.util.Optional<Type> |
getGenericParameterByName(java.lang.String name)
Get the type associated with the type parameter with the given name.
|
java.lang.String |
getId()
Id of the declaration.
|
java.lang.String |
getQualifiedName()
Qualified name of the declaration.
|
ReferenceTypeDeclaration |
getTypeDeclaration()
Corresponding TypeDeclaration
|
java.util.List<javaslang.Tuple2<TypeParameterDeclaration,Type>> |
getTypeParametersMap()
Get 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(Type other)
This method checks if ThisType t = new OtherType() would compile.
|
protected boolean |
isCorrespondingBoxingType(java.lang.String typeName) |
boolean |
isRawType() |
boolean |
isReferenceType()
Can this be seen as a ReferenceTypeUsage?
In other words: is this a reference to a class, an interface or an enum?
|
Type |
replaceTypeVariables(TypeParameterDeclaration tpToReplace,
Type replaced,
java.util.Map<TypeParameterDeclaration,Type> inferredTypes)
Replace all variables referring to the given TypeParameter with the given value.
|
java.lang.String |
toString() |
Type |
transformTypeParameters(TypeTransformer transformer)
Execute a transformation on all the type parameters of this element.
|
TypeParametersMap |
typeParametersMap() |
java.util.List<Type> |
typeParametersValues()
Get the values for all type parameters declared on this type.
|
java.util.Optional<Type> |
typeParamValue(TypeParameterDeclaration typeParameterDeclaration)
Calculate the value for the given type parameter.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
arrayLevel, asArrayType, asConstraintType, asPrimitive, asTypeParameter, asTypeVariable, asWildcard, isArray, isConstraint, isNull, isPrimitive, isReference, isTypeVariable, isVoid, isWildcard, replaceTypeVariables
useThisTypeParametersOnTheGivenType
protected ReferenceTypeDeclaration typeDeclaration
protected TypeSolver typeSolver
protected TypeParametersMap typeParametersMap
public ReferenceType(ReferenceTypeDeclaration typeDeclaration, TypeSolver typeSolver)
public ReferenceType(ReferenceTypeDeclaration typeDeclaration, java.util.List<Type> typeParameters, TypeSolver typeSolver)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public final boolean isReferenceType()
Type
isReferenceType
in interface Type
public ReferenceType asReferenceType()
asReferenceType
in interface Type
public Type transformTypeParameters(TypeTransformer transformer)
public Type replaceTypeVariables(TypeParameterDeclaration tpToReplace, Type replaced, java.util.Map<TypeParameterDeclaration,Type> inferredTypes)
Type
replaceTypeVariables
in interface Type
public abstract boolean isAssignableBy(Type other)
isAssignableBy
in interface Type
public java.util.List<ReferenceType> getAllAncestors()
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>.
public final java.util.List<ReferenceType> getAllInterfacesAncestors()
public final java.util.List<ReferenceType> getAllClassesAncestors()
public java.util.Optional<Type> getGenericParameterByName(java.lang.String name)
getGenericParameterByName
in interface TypeParameterValueProvider
public java.util.List<Type> typeParametersValues()
public java.util.List<javaslang.Tuple2<TypeParameterDeclaration,Type>> getTypeParametersMap()
public TypeParametersMap typeParametersMap()
typeParametersMap
in interface TypeParametrized
public final ReferenceTypeDeclaration getTypeDeclaration()
public java.util.Optional<Type> getFieldType(java.lang.String name)
public boolean hasName()
public java.lang.String getQualifiedName()
public java.lang.String getId()
public abstract java.util.Set<MethodUsage> getDeclaredMethods()
public boolean isRawType()
public java.util.Optional<Type> typeParamValue(TypeParameterDeclaration typeParameterDeclaration)
TypeParameterValueProvider
typeParamValue
in interface TypeParameterValueProvider
protected abstract ReferenceType create(ReferenceTypeDeclaration typeDeclaration, java.util.List<Type> typeParameters, TypeSolver typeSolver)
protected ReferenceType create(ReferenceTypeDeclaration typeDeclaration, TypeParametersMap typeParametersMap, TypeSolver typeSolver)
protected abstract ReferenceType create(ReferenceTypeDeclaration typeDeclaration, TypeSolver typeSolver)
protected boolean isCorrespondingBoxingType(java.lang.String typeName)
protected boolean compareConsideringTypeParameters(ReferenceType other)
public ReferenceType deriveTypeParameters(TypeParametersMap typeParametersMap)