Interface CtExecutableReference<T>

All Superinterfaces:
Cloneable, CtActualTypeContainer, CtElement, CtQueryable, CtReference, CtVisitable, FactoryAccessor, Serializable, SourcePositionHolder
All Known Implementing Classes:
CtExecutableReferenceImpl

public interface CtExecutableReference<T> extends CtReference, CtActualTypeContainer
This interface defines a reference to a CtExecutable. It can be a CtMethod or a CtConstructor.
  • Field Details

  • Method Details

    • isConstructor

      boolean isConstructor()
      Tells if this is a reference to a constructor.
    • getActualMethod

      Method getActualMethod()
      Gets the runtime method that corresponds to an executable reference if any.
      Returns:
      the method (null if not found)
    • getActualConstructor

      Constructor<?> getActualConstructor()
      Gets the runtime constructor that corresponds to an executable reference if any.
      Returns:
      the constructor (null if not found)
    • getDeclaration

      CtExecutable<T> getDeclaration()
      Description copied from interface: CtReference
      Returns the declaration that corresponds to the referenced element only if the declaration is in the analyzed source files. It is strongly advised to use the more robust CtTypeReference.getTypeDeclaration() and getExecutableDeclaration() that never return null.
      Specified by:
      getDeclaration in interface CtReference
      Returns:
      referenced element or null if element is not in the source path (aka input resource).
    • getExecutableDeclaration

      CtExecutable<T> getExecutableDeclaration()
      Returns a subtype CtExecutable 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 executable declaration that corresponds to the reference.
    • getDeclaringType

      CtTypeReference<?> getDeclaringType()
      Gets the reference to the type that declares this executable.
    • getType

      CtTypeReference<T> getType()
      For methods, gets the return type of the executable (may be null in noclasspath mode). For constructors, gets the constructor class (which is also the return type of the contructor calls).
    • getParameters

      List<CtTypeReference<?>> getParameters()
      Gets parameters of the executable.
    • setParameters

      <C extends CtExecutableReference<T>> C setParameters(List<CtTypeReference<?>> parameters)
      Sets parameters of the executable.
    • isOverriding

      boolean isOverriding(CtExecutableReference<?> executable)
      Returns true if this executable overrides the given executable.
    • getOverridingExecutable

      CtExecutableReference<?> getOverridingExecutable()
      Returns the method overridden by this one, if exists (null otherwise). The returned method is searched in the superclass hierarchy (and not in the super-interfaces). The returned method can be an abstract method from an abstract class, a super implementation, or even a method from Object.
    • getOverridingExecutable

      <S extends T> CtExecutableReference<S> getOverridingExecutable(CtTypeReference<?> subType)
      Gets an overriding executable for this executable from a given subtype, if exists.
      Type Parameters:
      S - subtype of T
      Parameters:
      subType - starting bottom type to find an overriding executable (subtypes are not tested)
      Returns:
      the first found (most concrete) executable that overrides this executable (null if none found)
    • isStatic

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

      <C extends CtExecutableReference<T>> C setDeclaringType(CtTypeReference<?> declaringType)
      Sets the declaring type.
    • setStatic

      <C extends CtExecutableReference<T>> C setStatic(boolean b)
      Sets this executable reference to be static or not.
    • setType

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

      boolean isFinal()
      Tells if the referenced executable is final.
    • getSignature

      String getSignature()
      Gets the signature of this method or constructor, as explained in CtExecutable.getSignature().
    • 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