|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ashridgetech.jamda.code.ClassGenerator.MethodGenerator
Generates a method in the code. May only be obtained from
ClassGenerator.addMethod(java.lang.String)
. After
setting the details, call ClassGenerator.getWriter()
to get
a JavaWriter
to which the method body may be written.
ClassGenerator.addMethod(java.lang.String)
Constructor Summary | |
protected |
ClassGenerator.MethodGenerator(java.lang.String name)
Create a MethodGenerator with the given name,
modifiers of PUBLIC, void return type and no parameters,
which may be abstract. |
Method Summary | |
ClassGenerator.MethodGenerator |
addModifiers(int modifiers)
Add modifiers to the existing modifiers. |
ClassGenerator.MethodGenerator |
addTag(java.lang.String tag)
Set an extra tag for the method Javadoc. |
ClassGenerator.MethodGenerator |
addThrows(java.lang.String exceptionName)
Add the name of an exception thrown by this method. |
ClassGenerator.MethodGenerator |
addThrows(java.lang.String exceptionName,
java.lang.String exceptionComment)
Add the name of an exception thrown by this method, with a Javadoc description. |
ClassGenerator.MethodGenerator |
description(java.lang.String comment)
Set the method description. |
void |
generate()
Generate this method's documentation, declaration and copy the code written to its writer()
into its containing ClassGenerator 's
ClassWriter . |
boolean |
isAbstract()
Indicate whether this method is abstract, as defined by the modifiers set by setModifiers(int) . |
ClassGenerator.MethodGenerator |
param(java.lang.String type,
java.lang.String name)
Add a parameter with no description. |
ClassGenerator.MethodGenerator |
param(java.lang.String type,
java.lang.String name,
java.lang.String comment)
Add a parameter. |
ClassGenerator.MethodGenerator |
returns(java.lang.String returnTypeName)
Set the return type name. |
ClassGenerator.MethodGenerator |
returns(java.lang.String returnTypeName,
java.lang.String comment)
Set the return type name. |
ClassGenerator.MethodGenerator |
setModifiers(int modifiers)
Replace the existing modifiers with modifiers . |
JavaWriter |
writer()
Get the JavaWriter to which the method code can be written. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
protected ClassGenerator.MethodGenerator(java.lang.String name)
MethodGenerator
with the given name,
modifiers of PUBLIC, void return type and no parameters,
which may be abstract.
name
- the method nameMethod Detail |
public ClassGenerator.MethodGenerator returns(java.lang.String returnTypeName)
returnTypeName
- the name of the return type - may be null
to indicate no return type for a constructor.
public ClassGenerator.MethodGenerator returns(java.lang.String returnTypeName, java.lang.String comment)
returnTypeName
- the name of the return type - may be null
to indicate no return type for a constructor.comment
- the description of the return type - must be null
if returnTypeName
is null
public ClassGenerator.MethodGenerator addModifiers(int modifiers)
modifiers
to the existing modifiers.
modifiers
- the modifiers to OR with the existing ones.
public ClassGenerator.MethodGenerator setModifiers(int modifiers)
modifiers
.
If the constructor
set this MethodGenerator
to abstract,
the abstract modifier will be added to those set.
modifiers
- the new modifiers.
public ClassGenerator.MethodGenerator description(java.lang.String comment)
comment
- the description of the method
public ClassGenerator.MethodGenerator addThrows(java.lang.String exceptionName)
exceptionName
- the name of the exception class
public ClassGenerator.MethodGenerator addThrows(java.lang.String exceptionName, java.lang.String exceptionComment)
exceptionName
- the name of the exception classexceptionComment
- the reason why the exception is thrown
public ClassGenerator.MethodGenerator addTag(java.lang.String tag)
returns(java.lang.String)
and param(java.lang.String, java.lang.String, java.lang.String)
.
tag
- the full text of the extra tag, such as
"@see Widget#grumble"
public ClassGenerator.MethodGenerator param(java.lang.String type, java.lang.String name, java.lang.String comment)
type
- the name of the type of this parameter - must not be nullname
- the name of this parameter - must not be nullcomment
- the description of this parameter - may be null
if there is no comment
public ClassGenerator.MethodGenerator param(java.lang.String type, java.lang.String name)
type
- the name of the type of this parameter - must not be nullname
- the name of this parameter - must not be null
public JavaWriter writer()
JavaWriter
to which the method code can be written.
JavaWriter
java.lang.IllegalStateException
- if this MethodGenerator
is abstractisAbstract()
public boolean isAbstract()
setModifiers(int)
.
public void generate()
writer()
into its containing ClassGenerator
's
ClassWriter
.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |