public final class MethodSpec extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
MethodSpec.Builder |
| 限定符和类型 | 字段和说明 |
|---|---|
List<AnnotationSpec> |
annotations |
CodeBlock |
code |
CodeBlock |
defaultValue |
List<TypeName> |
exceptions |
CodeBlock |
javadoc |
Set<Modifier> |
modifiers |
String |
name |
List<ParameterSpec> |
parameters |
TypeName |
returnType |
List<TypeVariableName> |
typeVariables |
boolean |
varargs |
| 限定符和类型 | 方法和说明 |
|---|---|
static MethodSpec.Builder |
constructorBuilder() |
boolean |
equals(Object o) |
int |
hashCode() |
boolean |
hasModifier(Modifier modifier) |
boolean |
isConstructor() |
static MethodSpec.Builder |
methodBuilder(String name) |
static MethodSpec.Builder |
overriding(ExecutableElement method)
Returns a new method spec builder that overrides
method. |
static MethodSpec.Builder |
overriding(ExecutableElement method,
DeclaredType enclosing,
Types types)
Returns a new method spec builder that overrides
method as a member of enclosing. |
MethodSpec.Builder |
toBuilder() |
String |
toString() |
public final String name
public final CodeBlock javadoc
public final List<AnnotationSpec> annotations
public final List<TypeVariableName> typeVariables
public final TypeName returnType
public final List<ParameterSpec> parameters
public final boolean varargs
public final CodeBlock code
public final CodeBlock defaultValue
public boolean hasModifier(Modifier modifier)
public boolean isConstructor()
public static MethodSpec.Builder methodBuilder(String name)
public static MethodSpec.Builder constructorBuilder()
public static MethodSpec.Builder overriding(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(ExecutableElement method, DeclaredType enclosing, 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 © 2025 fossc. All rights reserved.