Package org.jboss.jdeparser
Class AbstractJMethodDef
- java.lang.Object
-
- org.jboss.jdeparser.BasicJCommentable
-
- org.jboss.jdeparser.AbstractJDocCommentable
-
- org.jboss.jdeparser.BasicJAnnotatable
-
- org.jboss.jdeparser.AbstractJGeneric
-
- org.jboss.jdeparser.AbstractJMethodDef
-
- All Implemented Interfaces:
ClassContent
,JAnnotatable
,JCommentable
,JDocCommentable
,JGenericDef
,JMethodDef
,Writable
- Direct Known Subclasses:
ConstructorJMethodDef
,MethodJMethodDef
abstract class AbstractJMethodDef extends AbstractJGeneric implements JMethodDef, ClassContent
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList<AbstractJType>
_throws
private BasicJBlock
body
private AbstractJClassDef
clazz
private int
mods
private java.util.ArrayList<ImplJParamDeclaration>
params
-
Constructor Summary
Constructors Constructor Description AbstractJMethodDef(AbstractJClassDef clazz, int mods)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JBlock
_default()
A default method body for a JDK 8+ interface method.JMethodDef
_default(JExpr expr)
A default value for an annotation method.JComment
_throws(java.lang.Class<? extends java.lang.Throwable> type)
Get a@throws
doc comment block.JComment
_throws(java.lang.String type)
Get a@throws
doc comment block.JComment
_throws(JType type)
Get a@throws
doc comment block.private ImplJParamDeclaration
add(ImplJParamDeclaration item)
JBlock
body()
Get the method body.(package private) AbstractJClassDef
clazz()
(package private) int
getModifiers()
JParamDeclaration
param(int mods, java.lang.Class<?> type, java.lang.String name)
Add a parameter to this method.JParamDeclaration
param(int mods, java.lang.String type, java.lang.String name)
Add a parameter to this method.JParamDeclaration
param(int mods, JType type, java.lang.String name)
Add a parameter to this method.JParamDeclaration
param(java.lang.Class<?> type, java.lang.String name)
Add a parameter to this method.JParamDeclaration
param(java.lang.String type, java.lang.String name)
Add a parameter to this method.JParamDeclaration
param(JType type, java.lang.String name)
Add a parameter to this method.JParamDeclaration[]
params()
Get the list of parameters defined thus far.JComment
returnsDoc()
Get the@return
doc comment block.JParamDeclaration
varargParam(int mods, java.lang.Class<?> type, java.lang.String name)
Add a vararg parameter to this method.JParamDeclaration
varargParam(int mods, java.lang.String type, java.lang.String name)
Add a vararg parameter to this method.JParamDeclaration
varargParam(int mods, JType type, java.lang.String name)
Add a vararg parameter to this method.JParamDeclaration
varargParam(java.lang.Class<?> type, java.lang.String name)
Add a vararg parameter to this method.JParamDeclaration
varargParam(java.lang.String type, java.lang.String name)
Add a vararg parameter to this method.JParamDeclaration
varargParam(JType type, java.lang.String name)
Add a vararg parameter to this method.void
write(SourceFileWriter writer)
(package private) boolean
writeBody()
(package private) void
writePostfix(SourceFileWriter writer)
-
Methods inherited from class org.jboss.jdeparser.AbstractJGeneric
typeParam, typeParams, typeParamsToArgs, writeTypeParams
-
Methods inherited from class org.jboss.jdeparser.BasicJAnnotatable
annotate, annotate, annotate, writeAnnotations
-
Methods inherited from class org.jboss.jdeparser.AbstractJDocCommentable
deprecated, docComment, writeDocComments
-
Methods inherited from class org.jboss.jdeparser.BasicJCommentable
blockComment, lineComment, writeComments
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.jdeparser.JAnnotatable
annotate, annotate, annotate
-
Methods inherited from interface org.jboss.jdeparser.JCommentable
blockComment, lineComment
-
Methods inherited from interface org.jboss.jdeparser.JDocCommentable
deprecated, docComment
-
Methods inherited from interface org.jboss.jdeparser.JGenericDef
typeParam, typeParams
-
-
-
-
Field Detail
-
clazz
private final AbstractJClassDef clazz
-
mods
private int mods
-
params
private java.util.ArrayList<ImplJParamDeclaration> params
-
_throws
private java.util.ArrayList<AbstractJType> _throws
-
body
private BasicJBlock body
-
-
Constructor Detail
-
AbstractJMethodDef
AbstractJMethodDef(AbstractJClassDef clazz, int mods)
-
-
Method Detail
-
_default
public JBlock _default()
Description copied from interface:JMethodDef
A default method body for a JDK 8+ interface method.- Specified by:
_default
in interfaceJMethodDef
- Returns:
- the method body
-
_default
public JMethodDef _default(JExpr expr)
Description copied from interface:JMethodDef
A default value for an annotation method.- Specified by:
_default
in interfaceJMethodDef
- Parameters:
expr
- the value- Returns:
- this method definition
-
body
public JBlock body()
Description copied from interface:JMethodDef
Get the method body.- Specified by:
body
in interfaceJMethodDef
- Returns:
- the method body
-
returnsDoc
public JComment returnsDoc()
Description copied from interface:JMethodDef
Get the@return
doc comment block.- Specified by:
returnsDoc
in interfaceJMethodDef
- Returns:
- the comment block
-
add
private ImplJParamDeclaration add(ImplJParamDeclaration item)
-
param
public JParamDeclaration param(int mods, JType type, java.lang.String name)
Description copied from interface:JMethodDef
Add a parameter to this method.- Specified by:
param
in interfaceJMethodDef
- Parameters:
mods
- the parameter modifierstype
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
param
public JParamDeclaration param(JType type, java.lang.String name)
Description copied from interface:JMethodDef
Add a parameter to this method.- Specified by:
param
in interfaceJMethodDef
- Parameters:
type
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
param
public JParamDeclaration param(int mods, java.lang.String type, java.lang.String name)
Description copied from interface:JMethodDef
Add a parameter to this method.- Specified by:
param
in interfaceJMethodDef
- Parameters:
mods
- the parameter modifierstype
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
param
public JParamDeclaration param(java.lang.String type, java.lang.String name)
Description copied from interface:JMethodDef
Add a parameter to this method.- Specified by:
param
in interfaceJMethodDef
- Parameters:
type
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
param
public JParamDeclaration param(int mods, java.lang.Class<?> type, java.lang.String name)
Description copied from interface:JMethodDef
Add a parameter to this method.- Specified by:
param
in interfaceJMethodDef
- Parameters:
mods
- the parameter modifierstype
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
param
public JParamDeclaration param(java.lang.Class<?> type, java.lang.String name)
Description copied from interface:JMethodDef
Add a parameter to this method.- Specified by:
param
in interfaceJMethodDef
- Parameters:
type
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
varargParam
public JParamDeclaration varargParam(int mods, JType type, java.lang.String name)
Description copied from interface:JMethodDef
Add a vararg parameter to this method.- Specified by:
varargParam
in interfaceJMethodDef
- Parameters:
mods
- the parameter modifierstype
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
varargParam
public JParamDeclaration varargParam(JType type, java.lang.String name)
Description copied from interface:JMethodDef
Add a vararg parameter to this method.- Specified by:
varargParam
in interfaceJMethodDef
- Parameters:
type
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
varargParam
public JParamDeclaration varargParam(int mods, java.lang.String type, java.lang.String name)
Description copied from interface:JMethodDef
Add a vararg parameter to this method.- Specified by:
varargParam
in interfaceJMethodDef
- Parameters:
mods
- the parameter modifierstype
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
varargParam
public JParamDeclaration varargParam(java.lang.String type, java.lang.String name)
Description copied from interface:JMethodDef
Add a vararg parameter to this method.- Specified by:
varargParam
in interfaceJMethodDef
- Parameters:
type
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
varargParam
public JParamDeclaration varargParam(int mods, java.lang.Class<?> type, java.lang.String name)
Description copied from interface:JMethodDef
Add a vararg parameter to this method.- Specified by:
varargParam
in interfaceJMethodDef
- Parameters:
mods
- the parameter modifierstype
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
varargParam
public JParamDeclaration varargParam(java.lang.Class<?> type, java.lang.String name)
Description copied from interface:JMethodDef
Add a vararg parameter to this method.- Specified by:
varargParam
in interfaceJMethodDef
- Parameters:
type
- the parameter typename
- the parameter name- Returns:
- the parameter declaration
-
params
public JParamDeclaration[] params()
Description copied from interface:JMethodDef
Get the list of parameters defined thus far.- Specified by:
params
in interfaceJMethodDef
- Returns:
- the parameter list
-
_throws
public JComment _throws(java.lang.String type)
Description copied from interface:JMethodDef
Get a@throws
doc comment block.- Specified by:
_throws
in interfaceJMethodDef
- Parameters:
type
- the exception type- Returns:
- the doc comment block
-
_throws
public JComment _throws(JType type)
Description copied from interface:JMethodDef
Get a@throws
doc comment block.- Specified by:
_throws
in interfaceJMethodDef
- Parameters:
type
- the exception type- Returns:
- the doc comment block
-
_throws
public JComment _throws(java.lang.Class<? extends java.lang.Throwable> type)
Description copied from interface:JMethodDef
Get a@throws
doc comment block.- Specified by:
_throws
in interfaceJMethodDef
- Parameters:
type
- the exception type- Returns:
- the doc comment block
-
getModifiers
int getModifiers()
-
writeBody
boolean writeBody()
-
write
public void write(SourceFileWriter writer) throws java.io.IOException
-
writePostfix
void writePostfix(SourceFileWriter writer) throws java.io.IOException
- Throws:
java.io.IOException
-
clazz
AbstractJClassDef clazz()
-
-