Interface JFieldSymbol
- All Superinterfaces:
AnnotableSymbol
,JAccessibleElementSymbol
,JElementSymbol
,JVariableSymbol
Represents a field declaration.
- Since:
- 7.0.0
-
Field Summary
Fields inherited from interface net.sourceforge.pmd.lang.java.symbols.JAccessibleElementSymbol
PRIMITIVE_PACKAGE
-
Method Summary
Modifier and TypeMethodDescriptiondefault <R,
P> R acceptVisitor
(SymbolVisitor<R, P> visitor, P param) Dispatch to the appropriate visit method of the visitor and returns its result.default @Nullable Object
Returns the compile-time value of this field if this is a compile-time constant.@NonNull JClassSymbol
Returns the class that directly encloses this declaration.default @NonNull String
Returns the name of the package this element is declared in.boolean
Returns true if this field is an enum constant.default boolean
isField()
Returns true if this is a field symbol.default boolean
isFinal()
Returns true if this declaration is declared final.default ASTVariableId
Returns the node that declares this symbol.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
getModifiers, isStatic
Methods inherited from interface net.sourceforge.pmd.lang.java.symbols.JElementSymbol
equals, getSimpleName, getTypeSystem, isUnresolved, nameEquals
Methods inherited from interface net.sourceforge.pmd.lang.java.symbols.JVariableSymbol
getTypeMirror
-
Method Details
-
isField
default boolean isField()Description copied from interface:JVariableSymbol
Returns true if this is a field symbol.- Specified by:
isField
in interfaceJVariableSymbol
- See Also:
-
isEnumConstant
boolean isEnumConstant()Returns true if this field is an enum constant. -
isFinal
default boolean isFinal()Description copied from interface:JVariableSymbol
Returns true if this declaration is declared final. This takes implicit modifiers into account.- Specified by:
isFinal
in interfaceJVariableSymbol
-
getConstValue
Returns the compile-time value of this field if this is a compile-time constant. Otherwise returns null. -
getEnclosingClass
@NonNull JClassSymbol getEnclosingClass()Description copied from interface:JAccessibleElementSymbol
Returns the class that directly encloses this declaration. This is equivalent toClass.getEnclosingClass()
. Returns null if this is a top-level type declaration.This is necessarily an already resolved symbol, because 1. if it's obtained from reflection, then the enclosing class is available 2. if it's obtained from an AST, then the enclosing class is in the same source file so we can know about it
- Specified by:
getEnclosingClass
in interfaceJAccessibleElementSymbol
-
getPackageName
Description copied from interface:JAccessibleElementSymbol
Returns the name of the package this element is declared in. This recurses into the enclosing elements if needed. If this is an array symbol, returns the package name of the element symbol. If this is a primitive type, returns "java.lang".This is consistent with Java 9's
getPackageName()
.- Specified by:
getPackageName
in interfaceJAccessibleElementSymbol
-
acceptVisitor
Description copied from interface:JElementSymbol
Dispatch to the appropriate visit method of the visitor and returns its result.- Specified by:
acceptVisitor
in interfaceJElementSymbol
-
tryGetNode
Description copied from interface:JElementSymbol
Returns the node that declares this symbol. Eg forJMethodSymbol
, it's anASTMethodDeclaration
. Will only return non-null if the symbol is declared in the file currently being analysed.- Specified by:
tryGetNode
in interfaceJElementSymbol
-