Interface CtMethod<T>

All Superinterfaces:
Cloneable, CtBodyHolder, CtElement, CtExecutable<T>, CtFormalTypeDeclarer, CtModifiable, CtNamedElement, CtQueryable, CtShadowable, CtTypedElement<T>, CtTypeMember, CtVisitable, FactoryAccessor, Serializable, SourcePositionHolder
All Known Subinterfaces:
All Known Implementing Classes:
CtAnnotationMethodImpl, CtMethodImpl

public interface CtMethod<T> extends CtExecutable<T>, CtFormalTypeDeclarer, CtShadowable
This element defines a method declaration.
  • Method Details

    • isOverriding

      boolean isOverriding(CtMethod<?> superMethod)
      superMethod - to be checked method
      true if this method overrides `superMethod`.
      Returns true for itself too.
    • isDefaultMethod

      boolean isDefaultMethod()
      Checks if the method is a default method. Default method can be in interfaces from Java 8:
    • setDefaultMethod

      <C extends CtMethod<T>> C setDefaultMethod(boolean defaultMethod)
      Sets the default value state of a method.
    • clone

      CtMethod<T> 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 CtExecutable<T>
      Specified by:
      clone in interface CtNamedElement
    • getTopDefinitions

      Collection<CtMethod<?>> getTopDefinitions()
      Returns the top-most methods in the hierarchy defining this method (in super class and super interfaces). Returns the empty collection if defined here for the first time.
    • copyMethod

      CtMethod<?> copyMethod()
      Copy the method, where copy means cloning + porting all the references of the old method to the new method (important for recursive methods). The copied method is added to the type, with a suffix "Copy". A new unique method name is given for each copy, and this method can be called several times. If you want to rename the new method, use Refactoring.changeMethodName(CtMethod, String) (and not CtNamedElement.setSimpleName(String), which does not update the references)