Class MethodSpec

java.lang.Object
io.micronaut.sourcegen.javapoet.MethodSpec

public final class MethodSpec extends Object
A generated constructor or method declaration.
  • Field Details

  • Method Details

    • hasModifier

      public boolean hasModifier(Modifier modifier)
    • isConstructor

      public boolean isConstructor()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • methodBuilder

      public static MethodSpec.Builder methodBuilder(String name)
    • constructorBuilder

      public static MethodSpec.Builder constructorBuilder()
    • overriding

      public static MethodSpec.Builder overriding(ExecutableElement method)
      Returns a new method spec builder that overrides method.

      This will copy its visibility modifiers, type parameters, return type, name, parameters, and throws declarations. An Override annotation will be added.

      Note that in JavaPoet 1.2 through 1.7 this method retained annotations from the method and parameters of the overridden method. Since JavaPoet 1.8 annotations must be added separately.

    • overriding

      public static MethodSpec.Builder overriding(ExecutableElement method, DeclaredType enclosing, Types types)
      Returns a new method spec builder that overrides method as a member of enclosing. This will resolve type parameters: for example overriding Comparable.compareTo(T) in a type that implements Comparable<Movie>, the T parameter will be resolved to Movie.

      This will copy its visibility modifiers, type parameters, return type, name, parameters, and throws declarations. An Override annotation will be added.

      Note that in JavaPoet 1.2 through 1.7 this method retained annotations from the method and parameters of the overridden method. Since JavaPoet 1.8 annotations must be added separately.

    • toBuilder

      public MethodSpec.Builder toBuilder()