Interface JTypeDeclSymbol
-
- All Superinterfaces:
AnnotableSymbol
,JAccessibleElementSymbol
,JElementSymbol
- All Known Subinterfaces:
JClassSymbol
,JTypeParameterSymbol
public interface JTypeDeclSymbol extends JAccessibleElementSymbol
A symbol that declares a type. These includeNote: type symbols are not types, they declare types. See
JTypeMirror.getSymbol()
for more details.- Since:
- 7.0.0
-
-
Field Summary
-
Fields inherited from interface net.sourceforge.pmd.lang.java.symbols.JAccessibleElementSymbol
PRIMITIVE_PACKAGE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description @NonNull String
getSimpleName()
Returns the simple name of this class, as specified byClass.getSimpleName()
.default boolean
isInterface()
This returns true if this is an interface.default boolean
isUnresolved()
Returns true if this class is a symbolic reference to an unresolved class.-
Methods inherited from interface net.sourceforge.pmd.lang.java.symbols.AnnotableSymbol
getDeclaredAnnotation, getDeclaredAnnotations, isAnnotationPresent
-
Methods inherited from interface net.sourceforge.pmd.lang.java.symbols.JAccessibleElementSymbol
getEnclosingClass, getModifiers, getPackageName, isStatic
-
Methods inherited from interface net.sourceforge.pmd.lang.java.symbols.JElementSymbol
acceptVisitor, equals, getTypeSystem, nameEquals, tryGetNode
-
-
-
-
Method Detail
-
isUnresolved
default boolean isUnresolved()
Returns true if this class is a symbolic reference to an unresolved class. In that case no information about the symbol are known except its name, and the accessors of this class return default values.This kind of symbol is introduced to allow for some best-effort symbolic resolution. For example in:
and supposingimport org.Bar; Bar foo = new Bar();
org.Bar
is not on the classpath. The type offoo
isBar
, which we can qualify toorg.Bar
thanks to the import (via symbol tables, and without even querying the classpath). Even though we don't know what membersorg.Bar
has, a test fortypeIs("org.Bar")
would succeed with certainty, so it makes sense to preserve the name information and not give up too early.Note that unresolved types are always created from an unresolved canonical name, so they can't be just any type. For example, they can't be array types, nor local classes (since those are lexically scoped, so always resolvable), nor anonymous classes (can only be referenced on their declaration site), type variables, etc.
- Specified by:
isUnresolved
in interfaceJElementSymbol
-
getSimpleName
@NonNull String getSimpleName()
Returns the simple name of this class, as specified byClass.getSimpleName()
.- Specified by:
getSimpleName
in interfaceJElementSymbol
- Returns:
- the name
-
isInterface
default boolean isInterface()
This returns true if this is an interface. Annotation types are also interface types.
-
-