com.sun.codemodel
public class JMethod extends java.lang.Object implements JDeclaration, JAnnotatable
Modifier and Type | Method and Description |
---|---|
JMethod |
_throws(java.lang.Class exception) |
JMethod |
_throws(JClass exception)
Add an exception to the list of exceptions that this
method may throw.
|
JAnnotationUse |
annotate(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Adds an annotation to this variable.
|
JAnnotationUse |
annotate(JClass clazz)
Adds an annotation to this variable.
|
<W extends JAnnotationWriter> |
annotate2(java.lang.Class<W> clazz)
Adds an annotation to this program element
and returns a type-safe writer to fill in the values of such annotations.
|
JBlock |
body()
Get the block that makes up body of this method
|
void |
declare(JFormatter f) |
void |
declareDefaultValue(JExpression value)
Specify the default value for this annotation member
|
JTypeVar |
generify(java.lang.String name)
Adds a new type variable to this declaration.
|
JTypeVar |
generify(java.lang.String name,
java.lang.Class bound)
Adds a new type variable to this declaration with a bound.
|
JTypeVar |
generify(java.lang.String name,
JClass bound)
Adds a new type variable to this declaration with a bound.
|
JMods |
getMods()
Deprecated.
use
mods() |
boolean |
hasSignature(JType[] argTypes)
Returns true if the method has the specified signature.
|
boolean |
hasVarArgs()
Check if there are any varargs declared
for this method signature.
|
JDocComment |
javadoc()
Creates, if necessary, and returns the class javadoc for this
JDefinedClass
|
JVar[] |
listParams()
Returns all the parameters in an array.
|
JType[] |
listParamTypes()
Returns all the parameter types in an array.
|
JVar |
listVarParam()
Returns the variable parameter
|
JType |
listVarParamType()
Returns the varags parameter type.
|
JMods |
mods() |
java.lang.String |
name() |
void |
name(java.lang.String n)
Changes the name of the method.
|
protected JCodeModel |
owner() |
JVar |
param(java.lang.Class type,
java.lang.String name) |
JVar |
param(int mods,
java.lang.Class type,
java.lang.String name) |
JVar |
param(int mods,
JType type,
java.lang.String name)
Add the specified variable to the list of parameters
for this method signature.
|
JVar |
param(JType type,
java.lang.String name) |
JType |
type()
Returns the return type.
|
void |
type(JType t)
Overrides the return type.
|
JTypeVar[] |
typeParams()
Iterates all the type parameters of this class/interface.
|
JVar |
varParam(java.lang.Class type,
java.lang.String name) |
JVar |
varParam(JType type,
java.lang.String name)
Add the specified variable argument to the list of parameters
for this method signature.
|
public JMethod _throws(JClass exception)
exception
- Name of an exception that this method may throwpublic JMethod _throws(java.lang.Class exception)
public JVar param(int mods, JType type, java.lang.String name)
type
- JType of the parameter being addedname
- Name of the parameter being addedpublic JVar param(int mods, java.lang.Class type, java.lang.String name)
public JVar param(java.lang.Class type, java.lang.String name)
public JVar varParam(java.lang.Class type, java.lang.String name)
varParam(JType, String)
public JVar varParam(JType type, java.lang.String name)
type
- Type of the parameter being added.name
- Name of the parameter being addedjava.lang.IllegalStateException
- If this method is called twice.
varargs in J2SE 1.5 can appear only once in the
method signature.public JAnnotationUse annotate(JClass clazz)
annotate
in interface JAnnotatable
clazz
- The annotation class to annotate the field withpublic JAnnotationUse annotate(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
annotate
in interface JAnnotatable
clazz
- The annotation class to annotate the field withpublic <W extends JAnnotationWriter> W annotate2(java.lang.Class<W> clazz)
JAnnotatable
annotate2
in interface JAnnotatable
public boolean hasVarArgs()
public java.lang.String name()
public void name(java.lang.String n)
public JType type()
public void type(JType t)
public JType[] listParamTypes()
public JType listVarParamType()
public JVar[] listParams()
public JVar listVarParam()
public boolean hasSignature(JType[] argTypes)
public JBlock body()
public void declareDefaultValue(JExpression value)
value
- Default value for the annotation memberpublic JDocComment javadoc()
public void declare(JFormatter f)
declare
in interface JDeclaration
public JMods mods()
protected JCodeModel owner()
public JTypeVar generify(java.lang.String name)
JGenerifiable
generify
in interface JGenerifiable
public JTypeVar generify(java.lang.String name, java.lang.Class bound)
JGenerifiable
generify
in interface JGenerifiable
public JTypeVar generify(java.lang.String name, JClass bound)
JGenerifiable
generify
in interface JGenerifiable
public JTypeVar[] typeParams()
JGenerifiable
typeParams
in interface JGenerifiable
Copyright © 2005-2014 Sun Microsystems. All Rights Reserved.