public final class MethodSpec
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
MethodSpec.Builder |
Modifier and Type | Field and Description |
---|---|
java.util.List<AnnotationSpec> |
annotations |
CodeBlock |
code |
CodeBlock |
defaultValue |
java.util.List<TypeName> |
exceptions |
CodeBlock |
javadoc |
java.util.Set<javax.lang.model.element.Modifier> |
modifiers |
java.lang.String |
name |
java.util.List<ParameterSpec> |
parameters |
TypeName |
returnType |
java.util.List<TypeVariableName> |
typeVariables |
boolean |
varargs |
Modifier and Type | Method and Description |
---|---|
static MethodSpec.Builder |
constructorBuilder() |
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
boolean |
hasModifier(javax.lang.model.element.Modifier modifier) |
boolean |
isConstructor() |
static MethodSpec.Builder |
methodBuilder(java.lang.String name) |
static MethodSpec.Builder |
overriding(javax.lang.model.element.ExecutableElement method)
Returns a new method spec builder that overrides
method . |
static MethodSpec.Builder |
overriding(javax.lang.model.element.ExecutableElement method,
javax.lang.model.type.DeclaredType enclosing,
javax.lang.model.util.Types types)
Returns a new method spec builder that overrides
method as a member of enclosing . |
MethodSpec.Builder |
toBuilder() |
java.lang.String |
toString() |
public final java.lang.String name
public final CodeBlock javadoc
public final java.util.List<AnnotationSpec> annotations
public final java.util.Set<javax.lang.model.element.Modifier> modifiers
public final java.util.List<TypeVariableName> typeVariables
public final TypeName returnType
public final java.util.List<ParameterSpec> parameters
public final boolean varargs
public final java.util.List<TypeName> exceptions
public final CodeBlock code
public final CodeBlock defaultValue
public boolean hasModifier(javax.lang.model.element.Modifier modifier)
public boolean isConstructor()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public static MethodSpec.Builder methodBuilder(java.lang.String name)
public static MethodSpec.Builder constructorBuilder()
public static MethodSpec.Builder overriding(javax.lang.model.element.ExecutableElement method)
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.
public static MethodSpec.Builder overriding(javax.lang.model.element.ExecutableElement method, javax.lang.model.type.DeclaredType enclosing, javax.lang.model.util.Types types)
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.
public MethodSpec.Builder toBuilder()
Copyright © 2020 Square, Inc.. All Rights Reserved.