Class JMethod
java.lang.Object
com.sun.codemodel.JGenerifiableImpl
com.sun.codemodel.JMethod
- All Implemented Interfaces:
JAnnotatable, JDeclaration, JDocCommentable, JGenerifiable
public class JMethod
extends JGenerifiableImpl
implements JDeclaration, JAnnotatable, JDocCommentable
Java method.
-
Field Summary
FieldsModifier and TypeFieldDescriptionSet of exceptions that this method may throw.private List<JAnnotationUse> Annotations on this variable.private JBlockJBlock of statements that makes up the body this methodprivate JExpressionTo set the default value for the annotation memberprivate JDocCommentjavadoc comments for this JMethodprivate JModsModifiers for this methodprivate StringName of this methodprivate JDefinedClassList of parameters for this method's declarationprivate JTypeReturn type for this methodprivate JVarVariable parameter for this method's varargs declaration introduced in J2SE 1.5 -
Constructor Summary
ConstructorsConstructorDescriptionJMethod(int mods, JDefinedClass _class) Constructor constructorJMethod(JDefinedClass outer, int mods, JType type, String name) JMethod constructor -
Method Summary
Modifier and TypeMethodDescriptionAdd an exception to the list of exceptions that this method may throw.Adds an annotation to this variable.annotate(Class<? extends Annotation> clazz) Adds an annotation to this variable.<W extends JAnnotationWriter>
WAdds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.Read-only live view of all annotations on thisJAnnotatablebody()Get the block that makes up body of this methodvoidvoiddeclareDefaultValue(JExpression value) Specify the default value for this annotation membergetMods()Deprecated.booleanhasSignature(JType[] argTypes) Returns true if the method has the specified signature.booleanCheck if there are any varargs declared for this method signature.private booleanjavadoc()Creates, if necessary, and returns the class javadoc for this JDefinedClassJVar[]Returns all the parameters in an array.JType[]Returns all the parameter types in an array.Returns the variable parameterReturns the varags parameter type.mods()name()voidChanges the name of the method.protected JCodeModelowner()Add the specified variable to the list of parameters for this method signature.params()Returns the list of variable of this method.type()Returns the return type.voidOverrides the return type.Add the specified variable argument to the list of parameters for this method signature.Methods inherited from class JGenerifiableImpl
generify, generify, generify, typeParams
-
Field Details
-
mods
Modifiers for this method -
type
Return type for this method -
name
Name of this method -
params
-
_throws
-
body
JBlock of statements that makes up the body this method -
outer
-
jdoc
javadoc comments for this JMethod -
varParam
Variable parameter for this method's varargs declaration introduced in J2SE 1.5 -
annotations
Annotations on this variable. Lazily created. -
defaultValue
To set the default value for the annotation member
-
-
Constructor Details
-
JMethod
JMethod(JDefinedClass outer, int mods, JType type, String name) JMethod constructor- Parameters:
mods- Modifiers for this method's declarationtype- Return type for the methodname- Name of this method
-
JMethod
JMethod(int mods, JDefinedClass _class) Constructor constructor- Parameters:
mods- Modifiers for this constructor's declaration_class- JClass containing this constructor
-
-
Method Details
-
isConstructor
private boolean isConstructor() -
getThrows
-
_throws
-
_throws
-
params
-
param
-
param
-
param
-
param
-
varParam
-
varParam
Add the specified variable argument to the list of parameters for this method signature.- Parameters:
type- Type of the parameter being added.name- Name of the parameter being added- Returns:
- the variable parameter
- Throws:
IllegalStateException- If this method is called twice. varargs in J2SE 1.5 can appear only once in the method signature.
-
annotate
Adds an annotation to this variable.- Specified by:
annotatein interfaceJAnnotatable- Parameters:
clazz- The annotation class to annotate the field with
-
annotate
Adds an annotation to this variable.- Specified by:
annotatein interfaceJAnnotatable- Parameters:
clazz- The annotation class to annotate the field with
-
annotate2
Description copied from interface:JAnnotatableAdds an annotation to this program element and returns a type-safe writer to fill in the values of such annotations.- Specified by:
annotate2in interfaceJAnnotatable
-
annotations
Description copied from interface:JAnnotatableRead-only live view of all annotations on thisJAnnotatable- Specified by:
annotationsin interfaceJAnnotatable- Returns:
- Can be empty but never null.
-
hasVarArgs
public boolean hasVarArgs()Check if there are any varargs declared for this method signature. -
name
-
name
Changes the name of the method. -
type
Returns the return type. -
type
Overrides the return type. -
listParamTypes
Returns all the parameter types in an array.- Returns:
- If there's no parameter, an empty array will be returned.
-
listVarParamType
Returns the varags parameter type.- Returns:
- If there's no vararg parameter type, null will be returned.
-
listParams
Returns all the parameters in an array.- Returns:
- If there's no parameter, an empty array will be returned.
-
listVarParam
Returns the variable parameter- Returns:
- If there's no parameter, null will be returned.
-
hasSignature
Returns true if the method has the specified signature. -
body
-
declareDefaultValue
Specify the default value for this annotation member- Parameters:
value- Default value for the annotation member
-
javadoc
Creates, if necessary, and returns the class javadoc for this JDefinedClass- Specified by:
javadocin interfaceJDocCommentable- Returns:
- JDocComment containing javadocs for this class
-
declare
- Specified by:
declarein interfaceJDeclaration- Overrides:
declarein classJGenerifiableImpl
-
mods
- Returns:
- the current modifiers of this method. Always return non-null valid object.
-
getMods
-
owner
- Specified by:
ownerin classJGenerifiableImpl
-
mods()