Package com.squareup.javapoet
Class MethodSpec
java.lang.Object
com.squareup.javapoet.MethodSpec
A generated constructor or method declaration.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal List<AnnotationSpec>
final CodeBlock
(package private) static final String
final CodeBlock
final CodeBlock
final String
final List<ParameterSpec>
final TypeName
final List<TypeVariableName>
final boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic MethodSpec.Builder
(package private) void
emit
(CodeWriter codeWriter, String enclosingName, Set<Modifier> implicitModifiers) boolean
int
hashCode()
boolean
hasModifier
(Modifier modifier) boolean
private CodeBlock
private boolean
lastParameterIsArray
(List<ParameterSpec> parameters) static MethodSpec.Builder
methodBuilder
(String name) static MethodSpec.Builder
overriding
(ExecutableElement method) Returns a new method spec builder that overridesmethod
.static MethodSpec.Builder
overriding
(ExecutableElement method, DeclaredType enclosing, Types types) Returns a new method spec builder that overridesmethod
as a member ofenclosing
.toString()
-
Field Details
-
CONSTRUCTOR
- See Also:
-
name
-
javadoc
-
annotations
-
modifiers
-
typeVariables
-
returnType
-
parameters
-
varargs
public final boolean varargs -
exceptions
-
code
-
defaultValue
-
-
Constructor Details
-
MethodSpec
-
-
Method Details
-
lastParameterIsArray
-
emit
void emit(CodeWriter codeWriter, String enclosingName, Set<Modifier> implicitModifiers) throws IOException - Throws:
IOException
-
javadocWithParameters
-
hasModifier
-
isConstructor
public boolean isConstructor() -
equals
-
hashCode
public int hashCode() -
toString
-
methodBuilder
-
constructorBuilder
-
overriding
Returns a new method spec builder that overridesmethod
.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 overridesmethod
as a member ofenclosing
. This will resolve type parameters: for example overridingComparable.compareTo(T)
in a type that implementsComparable<Movie>
, theT
parameter will be resolved toMovie
.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
-