Top Description Fields Constructors Methods
com.github.javaparser.resolution.types

public abstract Class ResolvedReferenceType

extends Object
implements ResolvedType, ResolvedTypeParametrized, ResolvedTypeParameterValueProvider
Class Inheritance
All Implemented Interfaces
com.github.javaparser.resolution.types.parametrization.ResolvedTypeParameterValueProvider, com.github.javaparser.resolution.types.parametrization.ResolvedTypeParametrized, com.github.javaparser.resolution.types.ResolvedType
Imports
com.github.javaparser.ast.AccessSpecifier, com.github.javaparser.resolution.MethodUsage, com.github.javaparser.resolution.declarations.ResolvedFieldDeclaration, .ResolvedMethodDeclaration, .ResolvedReferenceTypeDeclaration, .ResolvedTypeParameterDeclaration, com.github.javaparser.resolution.types.parametrization.ResolvedTypeParameterValueProvider, .ResolvedTypeParametersMap, .ResolvedTypeParametrized, com.github.javaparser.utils.Pair, java.util.*, java.util.stream.Collectors

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 TypeField and Description
protected ResolvedReferenceTypeDeclaration
protected ResolvedTypeParametersMap

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public ResolvedReferenceType
protected boolean
protected abstract ResolvedReferenceType
create(ResolvedReferenceTypeDeclaration typeDeclaration, List<ResolvedType> typeParameters)

protected ResolvedReferenceType
protected abstract ResolvedReferenceType
private static List<ResolvedType>
public abstract ResolvedReferenceType
public String
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public abstract List<ResolvedReferenceType>
getAllAncestors()

Return all ancestors, that means all superclasses and interfaces.

public final List<ResolvedReferenceType>
public List<ResolvedFieldDeclaration>
getAllFieldsVisibleToInheritors()

Fields which are visible to inheritors.

public final List<ResolvedReferenceType>
public List<ResolvedMethodDeclaration>
getAllMethods()

Get a list of all the methods available on this type.

public List<ResolvedMethodDeclaration>
public abstract Set<ResolvedFieldDeclaration>
getDeclaredFields()

Fields declared on this type.

public abstract Set<MethodUsage>
getDeclaredMethods()

Methods declared on this type.

public abstract List<ResolvedReferenceType>
getDirectAncestors()

Return direct ancestors, that means the superclasses and interfaces implemented directly.

public Optional<ResolvedType>
getFieldType(String name)

The type of the field could be different from the one in the corresponding FieldDeclaration because type variables would be solved.

public Optional<ResolvedType>
public String
getId()

Id of the declaration.

public String
getQualifiedName()

Qualified name of the declaration.

public final ResolvedReferenceTypeDeclaration
getTypeDeclaration()

Corresponding TypeDeclaration

public List<Pair<ResolvedTypeParameterDeclaration, ResolvedType>>
getTypeParametersMap()

Get the values for all type parameters declared on this type.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public boolean
hasName()

Has the TypeDeclaration a name?

public abstract boolean
isAssignableBy(ResolvedType other)

Redeclares com.github.javaparser.resolution.types.ResolvedType.isAssignableBy.

This method checks if ThisType t = new OtherType() would compile.
protected boolean
public boolean
public final boolean
isReferenceType()

Overrides default com.github.javaparser.resolution.types.ResolvedType.isReferenceType.

Can this be seen as a ReferenceTypeUsage?
public ResolvedType
replaceTypeVariables(ResolvedTypeParameterDeclaration tpToReplace, ResolvedType replaced, Map<ResolvedTypeParameterDeclaration, ResolvedType> inferredTypes)

Overrides default com.github.javaparser.resolution.types.ResolvedType.replaceTypeVariables.

Replace all variables referring to the given TypeParameter with the given value.
public abstract ResolvedType
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public abstract ResolvedType
transformTypeParameters(ResolvedTypeTransformer transformer)

Execute a transformation on all the type parameters of this element.

public ResolvedTypeParametersMap
public List<ResolvedType>
typeParametersValues()

Get the values for all type parameters declared on this type.

public Optional<ResolvedType>
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

typeDeclarationback to summary
protected ResolvedReferenceTypeDeclaration typeDeclaration
typeParametersMapback to summary
protected ResolvedTypeParametersMap typeParametersMap

Constructor Detail

ResolvedReferenceTypeback to summary
public ResolvedReferenceType(ResolvedReferenceTypeDeclaration typeDeclaration)
ResolvedReferenceTypeback to summary
public ResolvedReferenceType(ResolvedReferenceTypeDeclaration typeDeclaration, List<ResolvedType> typeArguments)

Method Detail

asReferenceTypeback to summary
public ResolvedReferenceType asReferenceType()

Overrides default com.github.javaparser.resolution.types.ResolvedType.asReferenceType.

Annotations
@Override
compareConsideringTypeParametersback to summary
protected boolean compareConsideringTypeParameters(ResolvedReferenceType other)
createback to summary
protected abstract ResolvedReferenceType create(ResolvedReferenceTypeDeclaration typeDeclaration, List<ResolvedType> typeParameters)
createback to summary
protected ResolvedReferenceType create(ResolvedReferenceTypeDeclaration typeDeclaration, ResolvedTypeParametersMap typeParametersMap)
createback to summary
protected abstract ResolvedReferenceType create(ResolvedReferenceTypeDeclaration typeDeclaration)
deriveParamsback to summary
private static List<ResolvedType> deriveParams(ResolvedReferenceTypeDeclaration typeDeclaration)
deriveTypeParametersback to summary
public abstract ResolvedReferenceType deriveTypeParameters(ResolvedTypeParametersMap typeParametersMap)
describeback to summary
public String describe()

Implements com.github.javaparser.resolution.types.ResolvedType.describe.

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getAllAncestorsback to summary
public abstract List<ResolvedReferenceType> 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>.

getAllClassesAncestorsback to summary
public final List<ResolvedReferenceType> getAllClassesAncestors()
getAllFieldsVisibleToInheritorsback to summary
public List<ResolvedFieldDeclaration> 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.

getAllInterfacesAncestorsback to summary
public final List<ResolvedReferenceType> getAllInterfacesAncestors()
getAllMethodsback to summary
public List<ResolvedMethodDeclaration> 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.

getAllMethodsVisibleToInheritorsback to summary
public List<ResolvedMethodDeclaration> getAllMethodsVisibleToInheritors()
getDeclaredFieldsback to summary
public abstract Set<ResolvedFieldDeclaration> getDeclaredFields()

Fields declared on this type.

getDeclaredMethodsback to summary
public abstract Set<MethodUsage> getDeclaredMethods()

Methods declared on this type.

getDirectAncestorsback to summary
public abstract List<ResolvedReferenceType> 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.

getFieldTypeback to summary
public Optional<ResolvedType> getFieldType(String name)

The type of the field could be different from the one in the corresponding FieldDeclaration because type variables would be solved.

getGenericParameterByNameback to summary
public Optional<ResolvedType> getGenericParameterByName(String name)

Implements com.github.javaparser.resolution.types.parametrization.ResolvedTypeParameterValueProvider.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.

getIdback to summary
public String getId()

Id of the declaration. It corresponds to the qualified name, unless for local classes.

getQualifiedNameback to summary
public String getQualifiedName()

Qualified name of the declaration.

getTypeDeclarationback to summary
public final ResolvedReferenceTypeDeclaration getTypeDeclaration()

Corresponding TypeDeclaration

getTypeParametersMapback to summary
public List<Pair<ResolvedTypeParameterDeclaration, ResolvedType>> getTypeParametersMap()

Get the values for all type parameters declared on this type. In case of raw types the values correspond to TypeVariables.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
hasNameback to summary
public boolean hasName()

Has the TypeDeclaration a name? Anonymous classes do not have one.

isAssignableByback to summary
public abstract boolean isAssignableBy(ResolvedType other)

Redeclares com.github.javaparser.resolution.types.ResolvedType.isAssignableBy.

This method checks if ThisType t = new OtherType() would compile.

Annotations
@Override
isCorrespondingBoxingTypeback to summary
protected boolean isCorrespondingBoxingType(String typeName)
isRawTypeback to summary
public boolean isRawType()
isReferenceTypeback to summary
public final boolean isReferenceType()

Overrides default com.github.javaparser.resolution.types.ResolvedType.isReferenceType.

Doc from com.github.javaparser.resolution.types.ResolvedType.isReferenceType.

Can this be seen as a ReferenceTypeUsage? In other words: is this a reference to a class, an interface or an enum?

Annotations
@Override
replaceTypeVariablesback to summary
public ResolvedType replaceTypeVariables(ResolvedTypeParameterDeclaration tpToReplace, ResolvedType replaced, Map<ResolvedTypeParameterDeclaration, ResolvedType> inferredTypes)

Overrides default com.github.javaparser.resolution.types.ResolvedType.replaceTypeVariables.

Doc from com.github.javaparser.resolution.types.ResolvedType.replaceTypeVariables.

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.

Annotations
@Override
toRawTypeback to summary
public abstract ResolvedType toRawType()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
transformTypeParametersback to summary
public abstract ResolvedType transformTypeParameters(ResolvedTypeTransformer transformer)

Execute a transformation on all the type parameters of this element.

typeParametersMapback to summary
public ResolvedTypeParametersMap typeParametersMap()

Implements com.github.javaparser.resolution.types.parametrization.ResolvedTypeParametrized.typeParametersMap.

Annotations
@Override
typeParametersValuesback to summary
public List<ResolvedType> typeParametersValues()

Get the values for all type parameters declared on this type. The list can be empty for raw types.

typeParamValueback to summary
public Optional<ResolvedType> typeParamValue(ResolvedTypeParameterDeclaration typeParameterDeclaration)

Implements com.github.javaparser.resolution.types.parametrization.ResolvedTypeParameterValueProvider.typeParamValue.

Doc from com.github.javaparser.resolution.types.parametrization.ResolvedTypeParameterValueProvider.typeParamValue.

Calculate the value for the given type parameter. It could be inherited.