Class JVariableSig
- java.lang.Object
-
- net.sourceforge.pmd.lang.java.types.JVariableSig
-
- Direct Known Subclasses:
JVariableSig.FieldSig
public class JVariableSig extends Object
Represents avalue symbol
viewed in the context of a particular program point (ie under a particularSubstitution
).The type given to a symbol is context-dependent. For example, when looking in the supertypes of the current class for a field, we have:
abstract class Sup<K> { K field; // In this scope the type of `field` is `K`, an abstract type variable } class Foo extends Sup<Integer> { { // in this scope, the type of `super.field` is `Integer`, not `K`, // because we inherit `Sup` where `K` is substituted with `Integer`. // `K` is not even in scope. super.field = 2; } }
This interface plays a similar role to
JMethodSig
. It is the type of search results of aJSymbolTable
, seeJSymbolTable.variables()
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JVariableSig.FieldSig
A field signature.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
JTypeMirror
getDeclaringType()
This is the substituted type.JVariableSymbol
getSymbol()
Returns the symbol for this variable.JTypeMirror
getTypeMirror()
Returns the type given to the symbol in the particular scope this signature is valid in.int
hashCode()
String
toString()
-
-
-
Method Detail
-
getDeclaringType
public JTypeMirror getDeclaringType()
This is the substituted type. Eg in the example of the class javadoc, forsuper.field
, this would beSup<Integer>
. For local variables, this is always the generic type declaration of the enclosing type.
-
getSymbol
public JVariableSymbol getSymbol()
Returns the symbol for this variable.
-
getTypeMirror
public JTypeMirror getTypeMirror()
Returns the type given to the symbol in the particular scope this signature is valid in.
-
-