Top Methods
com.github.javaparser.resolution.declarations

public Interface ResolvedReferenceTypeDeclaration

extends ResolvedTypeDeclaration, ResolvedTypeParametrizable
Known Direct Subinterfaces
com.github.javaparser.resolution.declarations.ResolvedAnnotationDeclaration, com.github.javaparser.resolution.declarations.ResolvedClassDeclaration, com.github.javaparser.resolution.declarations.ResolvedEnumDeclaration, com.github.javaparser.resolution.declarations.ResolvedInterfaceDeclaration
Imports
com.github.javaparser.ast.AccessSpecifier, .Modifier, com.github.javaparser.resolution.MethodUsage, .UnsolvedSymbolException, com.github.javaparser.resolution.types.ResolvedReferenceType, .ResolvedType, java.util.ArrayList, .List, .Optional, .Set, java.util.stream.Collectors

Author
Federico Tomassetti

Method Summary

Modifier and TypeMethod and Description
public default ResolvedReferenceTypeDeclaration
public default boolean
canBeAssignedTo(ResolvedReferenceTypeDeclaration other)

Can we assign instances of the type defined by this declaration to variables having the type defined by the given type?

public default Optional<ResolvedTypeParameterDeclaration>
findTypeParameter(String name)

Implements com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable.findTypeParameter.

Find the closest TypeParameterDeclaration with the given name.
public default List<ResolvedReferenceType>
getAllAncestors()

The list of all the ancestors of the current declaration, direct and indirect.

public List<ResolvedFieldDeclaration>
getAllFields()

Return a list of all fields, either declared in this declaration or inherited.

public Set<MethodUsage>
getAllMethods()

Return a list of all the methods declared of this type declaration, either declared or inherited.

public default List<ResolvedFieldDeclaration>
getAllNonStaticFields()

Return a list of all the non static fields, either declared or inherited.

public default List<ResolvedFieldDeclaration>
getAllStaticFields()

Return a list of all the static fields, either declared or inherited.

public default List<ResolvedReferenceType>

Returns:

The list of resolved ancestors.
getAncestors
()

Resolves the types of all direct ancestors (i.e., the directly extended class and the directly implemented interfaces) and returns the list of ancestors as a list of resolved reference types.

public List<ResolvedReferenceType>

Returns:

The list of resolved ancestors.
getAncestors
(boolean
When set to false, this method throws an UnsolvedSymbolException if one or more ancestor could not be resolved. When set to true, this method does not throw an UnsolvedSymbolException, but the list of returned ancestors may be incomplete in case one or more ancestor could not be resolved.
acceptIncompleteList
)

Resolves the types of all direct ancestors (i.e., the directly extended class and the directly implemented interfaces) and returns the list of ancestors as a list of resolved reference types.

public List<ResolvedConstructorDeclaration>
public default List<ResolvedFieldDeclaration>
getDeclaredFields()

Return a list of all the fields declared in this type.

public Set<ResolvedMethodDeclaration>
getDeclaredMethods()

Return a list of all the methods declared in this type declaration.

public default ResolvedFieldDeclaration
getField(String name)

Note that the type of the field should be expressed using the type variables of this particular type.

public default ResolvedFieldDeclaration
getVisibleField(String name)

Consider only field or inherited field which is not private.

public default List<ResolvedFieldDeclaration>
getVisibleFields()

Return a list of all fields declared and the inherited ones which are not private.

public default boolean
hasAnnotation(String qualifiedName)

Has the type at least one annotation declared or inherited having the specified qualified name?

public boolean
hasDirectlyAnnotation(String qualifiedName)

Has the type at least one annotation declared having the specified qualified name?

public default boolean
hasField(String name)

Has this type a field with the given name?

public default boolean
hasVisibleField(String name)

Either a declared field or inherited field which is not private.

public boolean
isAssignableBy(ResolvedType type)

Can we assign instances of the given type to variables having the type defined by this declaration?

public boolean
isAssignableBy(ResolvedReferenceTypeDeclaration other)

Can we assign instances of the given type to variables having the type defined by this declaration?

public boolean
isFunctionalInterface()

This means that the type has a functional method.

Inherited from com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration:
asClassasEnumasInterfaceasTypeasTypeParametercontainerTypegetClassNamegetIdgetInternalTypegetPackageNamegetQualifiedNamehasInternalTypeinternalTypesisAnonymousClassisClassisEnumisInterfaceisTypeisTypeParameter
Inherited from com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable:
getTypeParametersisGeneric

Method Detail

asReferenceTypeback to summary
public default ResolvedReferenceTypeDeclaration asReferenceType()

Overrides default com.github.javaparser.resolution.declarations.ResolvedTypeDeclaration.asReferenceType.

Annotations
@Override
canBeAssignedToback to summary
public default boolean canBeAssignedTo(ResolvedReferenceTypeDeclaration other)

Can we assign instances of the type defined by this declaration to variables having the type defined by the given type?

findTypeParameterback to summary
public default Optional<ResolvedTypeParameterDeclaration> findTypeParameter(String name)

Implements com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable.findTypeParameter.

Doc from com.github.javaparser.resolution.declarations.ResolvedTypeParametrizable.findTypeParameter.

Find the closest TypeParameterDeclaration with the given name. It first look on this element itself and then on the containers.

Annotations
@Override
getAllAncestorsback to summary
public default List<ResolvedReferenceType> getAllAncestors()

The list of all the ancestors of the current declaration, direct and indirect. This list does not contains duplicates with the exacting same type parameters.

getAllFieldsback to summary
public List<ResolvedFieldDeclaration> getAllFields()

Return a list of all fields, either declared in this declaration or inherited.

getAllMethodsback to summary
public Set<MethodUsage> getAllMethods()

Return a list of all the methods declared of this type declaration, either declared or inherited. Note that it should not include overridden methods.

getAllNonStaticFieldsback to summary
public default List<ResolvedFieldDeclaration> getAllNonStaticFields()

Return a list of all the non static fields, either declared or inherited.

getAllStaticFieldsback to summary
public default List<ResolvedFieldDeclaration> getAllStaticFields()

Return a list of all the static fields, either declared or inherited.

getAncestorsback to summary
public default List<ResolvedReferenceType> getAncestors()

Resolves the types of all direct ancestors (i.e., the directly extended class and the directly implemented interfaces) and returns the list of ancestors as a list of resolved reference types.

In case any ancestor cannot be resolved, an UnsolvedSymbolException is thrown. In order to obtain a list of only the resolvable direct ancestors, use getAncestors(boolean) and pass the value true.

Note that an ancestor can be parametrized types with values specified. For example:

class A implements Comparable<String> {}

In this case the ancestor is Comparable<String>

Returns:List<ResolvedReferenceType>

The list of resolved ancestors.

Exceptions
UnsolvedSymbolException:
if some ancestor could not be resolved.
getAncestorsback to summary
public List<ResolvedReferenceType> getAncestors(boolean acceptIncompleteList)

Resolves the types of all direct ancestors (i.e., the directly extended class and the directly implemented interfaces) and returns the list of ancestors as a list of resolved reference types.

If acceptIncompleteList is false, then an UnsolvedSymbolException is thrown if any ancestor cannot be resolved. Otherwise, a list of only the resolvable direct ancestors is returned.

Parameters
acceptIncompleteList:boolean

When set to false, this method throws an UnsolvedSymbolException if one or more ancestor could not be resolved. When set to true, this method does not throw an UnsolvedSymbolException, but the list of returned ancestors may be incomplete in case one or more ancestor could not be resolved.

Returns:List<ResolvedReferenceType>

The list of resolved ancestors.

Exceptions
UnsolvedSymbolException:
if some ancestor could not be resolved and acceptIncompleteList is set to false.
getConstructorsback to summary
public List<ResolvedConstructorDeclaration> getConstructors()
getDeclaredFieldsback to summary
public default List<ResolvedFieldDeclaration> getDeclaredFields()

Return a list of all the fields declared in this type.

getDeclaredMethodsback to summary
public Set<ResolvedMethodDeclaration> getDeclaredMethods()

Return a list of all the methods declared in this type declaration.

getFieldback to summary
public default ResolvedFieldDeclaration getField(String name)

Note that the type of the field should be expressed using the type variables of this particular type. Consider for example:

class Foo { E field; }

class Bar extends Foo { }

When calling getField("field") on Foo I should get a FieldDeclaration with type E, while calling it on Bar I should get a FieldDeclaration with type String.

getVisibleFieldback to summary
public default ResolvedFieldDeclaration getVisibleField(String name)

Consider only field or inherited field which is not private.

getVisibleFieldsback to summary
public default List<ResolvedFieldDeclaration> getVisibleFields()

Return a list of all fields declared and the inherited ones which are not private.

hasAnnotationback to summary
public default boolean hasAnnotation(String qualifiedName)

Has the type at least one annotation declared or inherited having the specified qualified name?

hasDirectlyAnnotationback to summary
public boolean hasDirectlyAnnotation(String qualifiedName)

Has the type at least one annotation declared having the specified qualified name?

hasFieldback to summary
public default boolean hasField(String name)

Has this type a field with the given name?

hasVisibleFieldback to summary
public default boolean hasVisibleField(String name)

Either a declared field or inherited field which is not private.

isAssignableByback to summary
public boolean isAssignableBy(ResolvedType type)

Can we assign instances of the given type to variables having the type defined by this declaration?

isAssignableByback to summary
public boolean isAssignableBy(ResolvedReferenceTypeDeclaration other)

Can we assign instances of the given type to variables having the type defined by this declaration?

isFunctionalInterfaceback to summary
public boolean isFunctionalInterface()

This means that the type has a functional method. Conceptually, a functional interface has exactly one abstract method. Typically these classes has the FunctionInterface annotation but this is not mandatory.