Interface CtVariableReference<T>

All Superinterfaces:
Cloneable, CtElement, CtQueryable, CtReference, CtVisitable, FactoryAccessor, Serializable, SourcePositionHolder
All Known Subinterfaces:
CtCatchVariableReference<T>, CtFieldReference<T>, CtLocalVariableReference<T>, CtParameterReference<T>, CtUnboundVariableReference<T>
All Known Implementing Classes:
CtCatchVariableReferenceImpl, CtFieldReferenceImpl, CtLocalVariableReferenceImpl, CtParameterReferenceImpl, CtUnboundVariableReferenceImpl, CtVariableReferenceImpl

public interface CtVariableReference<T> extends CtReference
This interface defines a reference to a CtVariable or sub-type.
  • Method Details

    • getType

      CtTypeReference<T> getType()
      Gets the type of the variable.
    • setType

      <C extends CtVariableReference<T>> C setType(CtTypeReference type)
      Sets the type of the variable.
    • getDeclaration

      CtVariable<T> getDeclaration()
      Tries to get the declaration of the reference.
      Specified by:
      getDeclaration in interface CtReference
      Returns:
      referenced element or null if element is not in the source path (aka input resource).
    • getModifiers

      Set<ModifierKind> getModifiers()
      Gets modifiers of the reference.
    • clone

      Description copied from interface: CtElement
      Clone the element which calls this method in a new object. Note that that references are kept as is, and thus, so if you clone whole classes or methods, some parts of the cloned element (eg executable references) may still point to the initial element. In this case, consider using methods Refactoring.copyType(CtType) and Refactoring.copyMethod(CtMethod) instead which does additional work beyond cloning.
      Specified by:
      clone in interface CtElement
      Specified by:
      clone in interface CtReference
      Returns:
      a clone of this element. All children are cloned, but the parent of the returned clone is set to null.