Interface CtFieldReference<T>

All Superinterfaces:
Cloneable, CtElement, CtQueryable, CtReference, CtVariableReference<T>, CtVisitable, FactoryAccessor, Serializable, SourcePositionHolder
All Known Implementing Classes:
CtFieldReferenceImpl

public interface CtFieldReference<T> extends CtVariableReference<T>
This interface defines a reference to a CtField.
  • Method Details

    • getActualField

      Member getActualField()
      Gets the runtime member that corresponds to a field reference if any.
      Returns:
      the member (null if not found)
    • getDeclaration

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

      CtField<T> getFieldDeclaration()
      Returns the CtField that corresponds to the reference even if its declaring type isn't in the Spoon source path (in this case, the Spoon elements are built with runtime reflection)
      Returns:
      the field declaration that corresponds to the reference.
    • getDeclaringType

      CtTypeReference<?> getDeclaringType()
      Gets the type in which the field is declared.
    • getQualifiedName

      String getQualifiedName()
      Gets the qualified name of the field.
    • isFinal

      boolean isFinal()
      Tells if the referenced field is final.
    • isStatic

      boolean isStatic()
      Tells if the referenced field is static.
    • setDeclaringType

      <C extends CtFieldReference<T>> C setDeclaringType(CtTypeReference<?> declaringType)
      Sets the type in which the field is declared.
    • setFinal

      <C extends CtFieldReference<T>> C setFinal(boolean b)
      Forces a reference to a final element.
    • setStatic

      <C extends CtFieldReference<T>> C setStatic(boolean b)
      Forces a reference to a static element.
    • 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
      Specified by:
      clone in interface CtVariableReference<T>