|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.arch4j.generator.JavaDefinition | +--org.arch4j.generator.JavaFunctionDefinition | +--org.arch4j.generator.JavaMethodDefinition
This class is used to define the attributes of a Java method. The attributes can then be used to generate a valid Java method definition string.
The number of constructors are meant to make it easy to define a method with as few statements as possible.
If left uninitialized, the access control modifier for the method defaults to public access.
Field Summary | |
protected boolean |
isAbstract
Is the method abstract? Default = false. |
protected boolean |
isFinal
Is the method final? Default = false. |
protected boolean |
isInterface
Is the method part of an interface? Default = false. |
protected boolean |
isNative
Is the method native? Default = false. |
protected boolean |
isStatic
Is the method static? Default = false. |
protected boolean |
isSynchronized
Is the method synchronized? Default = false. |
protected JavaIdentifier |
methodIdentifier
|
Fields inherited from class org.arch4j.generator.JavaFunctionDefinition |
codeBlock, exceptions, parameters |
Fields inherited from class org.arch4j.generator.JavaDefinition |
accessModifier, comment |
Fields inherited from interface org.arch4j.generator.JavaKeywordConstants |
ABSTRACT, CATCH, CLASS, DEFAULT_ACCESS, EXTENDS, FALSE, FINAL, FINALLY, IMPLEMENTS, IMPORT, INTERFACE, NATIVE, NEW, NULL, PACKAGE, PRIVATE, PROTECTED, PUBLIC, RETURN, STATIC, STRICTFP, SUPER, SYNCHRONIZED, THIS, THROW, THROWS, TRANSIENT, TRUE, TRY, VOID, VOLATILE |
Fields inherited from interface org.arch4j.generator.JavaPrimitiveConstants |
BOOLEAN, BYTE, CHAR, DOUBLE, FLOAT, INT, LONG, SHORT |
Constructor Summary | |
JavaMethodDefinition(JavaIdentifier methodIdentifier,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
method identifier, list of formal parameters,
list of thrown exceptions, and code block. |
|
JavaMethodDefinition(JavaIdentifier methodIdentifier,
List parameters,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
method identifier, list of formal parameters,
and code block. |
|
JavaMethodDefinition(JavaIdentifier methodIdentifier,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
method identifier and code block. |
|
JavaMethodDefinition(String comment,
JavaAccessModifier accessModifier,
boolean isAbstract,
boolean isFinal,
boolean isStatic,
boolean isSynchronized,
boolean isNative,
JavaIdentifier methodIdentifier,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
comment, access control modifier, method identifier,
list of formal parameters, list of thrown exceptions, code block,
whether the method is abstract or final,
whether the method is static, synchronized or both,
and whether the method is native. |
|
JavaMethodDefinition(String comment,
JavaAccessModifier accessModifier,
boolean isAbstract,
boolean isFinal,
boolean isStatic,
boolean isSynchronized,
JavaIdentifier methodIdentifier,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
comment, access control modifier, method identifier,
list of formal parameters, list of thrown exceptions, code block,
whether the method is abstract or final,
and whether the method is static, synchronized or both. |
|
JavaMethodDefinition(String comment,
JavaAccessModifier accessModifier,
JavaIdentifier methodIdentifier,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
comment, access control modifier, method identifier,
list of formal parameters, list of thrown exceptions, and code block. |
|
JavaMethodDefinition(String comment,
JavaAccessModifier accessModifier,
JavaIdentifier methodIdentifier,
List parameters,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
comment, access control modifier, method identifier,
list of formal parameters, and code block. |
|
JavaMethodDefinition(String comment,
JavaAccessModifier accessModifier,
JavaIdentifier methodIdentifier,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
comment, access control modifier, method identifier,
and code block. |
|
JavaMethodDefinition(String comment,
String accessModifier,
boolean isAbstract,
boolean isFinal,
boolean isStatic,
boolean isSynchronized,
boolean isNative,
String methodReturnType,
String methodName,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
comment, access control modifier, method return type, method name,
list of formal parameters, list of thrown exceptions, code block,
whether the method is abstract or final,
whether the method is static, synchronized or both,
and whether the method is native. |
|
JavaMethodDefinition(String comment,
String accessModifier,
boolean isAbstract,
boolean isFinal,
boolean isStatic,
boolean isSynchronized,
String methodReturnType,
String methodName,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
comment, access control modifier, method return type, method name,
list of formal parameters, list of thrown exceptions, code block,
whether the method is abstract or final,
and whether the method is static, synchronized or both. |
|
JavaMethodDefinition(String methodReturnType,
String methodName,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
method return type, method name, list of formal parameters,
list of thrown exceptions, and code block. |
|
JavaMethodDefinition(String methodReturnType,
String methodName,
List parameters,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
method return type, method name, list of formal parameters,
and code block. |
|
JavaMethodDefinition(String methodReturnType,
String methodName,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
method return type and code block. |
|
JavaMethodDefinition(String comment,
String accessModifier,
String methodReturnType,
String methodName,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
comment, access control modifier, method return type, method name,
list of formal parameters, list of thrown exceptions, and code block. |
|
JavaMethodDefinition(String comment,
String accessModifier,
String methodReturnType,
String methodName,
List parameters,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
comment, access control modifier, method return type, method name,
list of formal parameters, and code block. |
|
JavaMethodDefinition(String comment,
String accessModifier,
String methodReturnType,
String methodName,
String codeBlock)
Constructs a JavaMethodDefinition with the specified
comment, access control modifier, method return type, method name,
and code block. |
Method Summary | |
protected String |
getDefaultComment()
Returns a simple, descriptive, one line comment for the function. |
List |
getImports()
Returns a list of potential import types for the function. |
JavaIdentifier |
getMethodIdentifier()
Returns the method's identifier. |
String |
getName()
Returns the method's name. |
String |
getPackageName()
Returns the method's return type package name. |
protected String |
getReturnComment()
Returns a javadoc @return string. |
String |
getType()
Returns the method's return type. |
protected boolean |
hasReturnType()
Returns whether the function has a return type or not. |
boolean |
isAbstract()
Returns whether the method is abstract or not. |
boolean |
isFinal()
Returns whether the method is final or not. |
boolean |
isInterface()
Returns whether the method is part of an interface or not. |
boolean |
isNative()
Returns whether the method is native or not. |
boolean |
isStatic()
Returns whether the method is static or not. |
boolean |
isSynchronized()
Returns whether the method is synchronized or not. |
void |
setAbstract(boolean value)
Set whether the method is abstract or not. |
void |
setFinal(boolean value)
Set whether the method is final or not. |
void |
setInterface(boolean value)
Set whether the method is part of an interface or not. |
void |
setNative(boolean value)
Set whether the method is native or not. |
void |
setStatic(boolean value)
Set whether the method is static or not. |
void |
setSynchronized(boolean value)
Set whether the method is synchronized or not. |
void |
writeDefinitionTo(CodeBuffer buffer)
Write the Java source representation of the method to the CodeBuffer . |
Methods inherited from class org.arch4j.generator.JavaFunctionDefinition |
addException, addException, addExceptions, addParameter, addParameter, addParameter, addParameters, getCodeBlock, getExceptions, getFormattedComment, getParameters, hasExceptions, hasParameters, setExceptions, setParameters |
Methods inherited from class org.arch4j.generator.JavaDefinition |
getAccessModifier, getComment, getDefinition, hasComment, setAccessModifier, setComment |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean isInterface
protected boolean isAbstract
protected boolean isFinal
protected boolean isStatic
protected boolean isSynchronized
protected boolean isNative
protected JavaIdentifier methodIdentifier
Constructor Detail |
public JavaMethodDefinition(String methodReturnType, String methodName, String codeBlock)
JavaMethodDefinition
with the specified
method return type and code block.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
methodReturnType
- The method's return type.methodName
- The method's name.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(JavaIdentifier methodIdentifier, String codeBlock)
JavaMethodDefinition
with the specified
method identifier and code block.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
methodIdentifier
- The method's identifier (return type and name).codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String methodReturnType, String methodName, List parameters, String codeBlock)
JavaMethodDefinition
with the specified
method return type, method name, list of formal parameters,
and code block.
The parameter list should contain JavaIdentifier
objects.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
methodReturnType
- The method's return type.methodName
- The method's name.parameters
- The list of formal parameters the method accepts.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(JavaIdentifier methodIdentifier, List parameters, String codeBlock)
JavaMethodDefinition
with the specified
method identifier, list of formal parameters,
and code block.
The parameter list should contain JavaIdentifier
objects.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
methodIdentifier
- The method's identifier (return type and name).parameters
- The list of formal parameters the method accepts.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String methodReturnType, String methodName, List parameters, List exceptions, String codeBlock)
JavaMethodDefinition
with the specified
method return type, method name, list of formal parameters,
list of thrown exceptions, and code block.
The parameter list should contain JavaIdentifier
objects.
The exception list should contain JavaType
objects,
although Strings will be converted if it is more convenient to use Strings.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
methodReturnType
- The method's return type.methodName
- The method's name.parameters
- The list of formal parameters the method accepts.exceptions
- The list of exceptions thrown by the method.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(JavaIdentifier methodIdentifier, List parameters, List exceptions, String codeBlock)
JavaMethodDefinition
with the specified
method identifier, list of formal parameters,
list of thrown exceptions, and code block.
The parameter list should contain JavaIdentifier
objects.
The exception list should contain JavaType
objects,
although Strings will be converted if it is more convenient to use Strings.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
methodIdentifier
- The method's identifier (return type and name).parameters
- The list of formal parameters the method accepts.exceptions
- The list of exceptions thrown by the method.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String comment, String accessModifier, String methodReturnType, String methodName, String codeBlock)
JavaMethodDefinition
with the specified
comment, access control modifier, method return type, method name,
and code block.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The method's descriptive comment.accessModifier
- The method's access control modifier.methodReturnType
- The method's return type.methodName
- The method's name.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String comment, JavaAccessModifier accessModifier, JavaIdentifier methodIdentifier, String codeBlock)
JavaMethodDefinition
with the specified
comment, access control modifier, method identifier,
and code block.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The method's descriptive comment.accessModifier
- The method's access control modifier.methodIdentifier
- The method's identifier (return type and name).codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String comment, String accessModifier, String methodReturnType, String methodName, List parameters, String codeBlock)
JavaMethodDefinition
with the specified
comment, access control modifier, method return type, method name,
list of formal parameters, and code block.
The parameter list should contain JavaIdentifier
objects.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The method's descriptive comment.accessModifier
- The method's access control modifier.methodReturnType
- The method's return type.methodName
- The method's name.parameters
- The list of formal parameters the method accepts.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String comment, JavaAccessModifier accessModifier, JavaIdentifier methodIdentifier, List parameters, String codeBlock)
JavaMethodDefinition
with the specified
comment, access control modifier, method identifier,
list of formal parameters, and code block.
The parameter list should contain JavaIdentifier
objects.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The method's descriptive comment.accessModifier
- The method's access control modifier.methodIdentifier
- The method's identifier (return type and name).parameters
- The list of formal parameters the method accepts.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String comment, String accessModifier, String methodReturnType, String methodName, List parameters, List exceptions, String codeBlock)
JavaMethodDefinition
with the specified
comment, access control modifier, method return type, method name,
list of formal parameters, list of thrown exceptions, and code block.
The parameter list should contain JavaIdentifier
objects.
The exception list should contain JavaType
objects,
although Strings will be converted if it is more convenient to use Strings.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The method's descriptive comment.accessModifier
- The method's access control modifier.methodReturnType
- The method's return type.methodName
- The method's name.parameters
- The list of formal parameters the method accepts.exceptions
- The list of exceptions thrown by the method.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String comment, JavaAccessModifier accessModifier, JavaIdentifier methodIdentifier, List parameters, List exceptions, String codeBlock)
JavaMethodDefinition
with the specified
comment, access control modifier, method identifier,
list of formal parameters, list of thrown exceptions, and code block.
The parameter list should contain JavaIdentifier
objects.
The exception list should contain JavaType
objects,
although Strings will be converted if it is more convenient to use Strings.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The method's descriptive comment.accessModifier
- The method's access control modifier.methodIdentifier
- The method's identifier (return type and name).parameters
- The list of formal parameters the method accepts.exceptions
- The list of exceptions thrown by the method.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String comment, String accessModifier, boolean isAbstract, boolean isFinal, boolean isStatic, boolean isSynchronized, String methodReturnType, String methodName, List parameters, List exceptions, String codeBlock)
JavaMethodDefinition
with the specified
comment, access control modifier, method return type, method name,
list of formal parameters, list of thrown exceptions, code block,
whether the method is abstract or final,
and whether the method is static, synchronized or both.
A method cannot be both abstract and final, so if both are
specified as true
, the method will be declared abstract.
The parameter list should contain JavaIdentifier
objects.
The exception list should contain JavaType
objects,
although Strings will be converted if it is more convenient to use Strings.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The method's descriptive comment.accessModifier
- The method's access control modifier.isAbstract
- true if the method is defined to be abstract.isFinal
- true if the method is defined to be final.isStatic
- true if the method is defined to be static.isSynchronized
- true if the method must be synchronized.methodReturnType
- The method's return type.methodName
- The method's name.parameters
- The list of formal parameters the method accepts.exceptions
- The list of exceptions thrown by the method.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String comment, JavaAccessModifier accessModifier, boolean isAbstract, boolean isFinal, boolean isStatic, boolean isSynchronized, JavaIdentifier methodIdentifier, List parameters, List exceptions, String codeBlock)
JavaMethodDefinition
with the specified
comment, access control modifier, method identifier,
list of formal parameters, list of thrown exceptions, code block,
whether the method is abstract or final,
and whether the method is static, synchronized or both.
A method cannot be both abstract and final, so if both are
specified as true
, the method will be declared abstract.
The parameter list should contain JavaIdentifier
objects.
The exception list should contain JavaType
objects,
although Strings will be converted if it is more convenient to use Strings.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The method's descriptive comment.accessModifier
- The method's access control modifier.isAbstract
- true if the method is defined to be abstract.isFinal
- true if the method is defined to be final.isStatic
- true if the method is defined to be static.isSynchronized
- true if the method must be synchronized.methodIdentifier
- The method's identifier (return type and name).parameters
- The list of formal parameters the method accepts.exceptions
- The list of exceptions thrown by the method.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String comment, String accessModifier, boolean isAbstract, boolean isFinal, boolean isStatic, boolean isSynchronized, boolean isNative, String methodReturnType, String methodName, List parameters, List exceptions, String codeBlock)
JavaMethodDefinition
with the specified
comment, access control modifier, method return type, method name,
list of formal parameters, list of thrown exceptions, code block,
whether the method is abstract or final,
whether the method is static, synchronized or both,
and whether the method is native.
A method cannot be both abstract and final, so if both are
specified as true
, the method will be declared abstract.
The parameter list should contain JavaIdentifier
objects.
The exception list should contain JavaType
objects,
although Strings will be converted if it is more convenient to use Strings.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The method's descriptive comment.accessModifier
- The method's access control modifier.isAbstract
- true if the method is defined to be abstract.isFinal
- true if the method is defined to be final.isStatic
- true if the method is defined to be static.isSynchronized
- true if the method must be synchronized.methodReturnType
- The method's return type.methodName
- The method's name.parameters
- The list of formal parameters the method accepts.exceptions
- The list of exceptions thrown by the method.codeBlock
- The statements defining the body of the method.public JavaMethodDefinition(String comment, JavaAccessModifier accessModifier, boolean isAbstract, boolean isFinal, boolean isStatic, boolean isSynchronized, boolean isNative, JavaIdentifier methodIdentifier, List parameters, List exceptions, String codeBlock)
JavaMethodDefinition
with the specified
comment, access control modifier, method identifier,
list of formal parameters, list of thrown exceptions, code block,
whether the method is abstract or final,
whether the method is static, synchronized or both,
and whether the method is native.
A method cannot be both abstract and final, so if both are
specified as true
, the method will be declared abstract.
The parameter list should contain JavaIdentifier
objects.
The exception list should contain JavaType
objects,
although Strings will be converted if it is more convenient to use Strings.
If the code block contains more than one line, format it with a
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The method's descriptive comment.accessModifier
- The method's access control modifier.isAbstract
- true if the method is defined to be abstract.isFinal
- true if the method is defined to be final.isStatic
- true if the method is defined to be static.isSynchronized
- true if the method must be synchronized.methodIdentifier
- The method's identifier (return type and name).parameters
- The list of formal parameters the method accepts.exceptions
- The list of exceptions thrown by the method.codeBlock
- The statements defining the body of the method.Method Detail |
public boolean isInterface()
public void setInterface(boolean value)
value
- true for part of an interface.public boolean isAbstract()
public void setAbstract(boolean value)
Note: Calling this method with true
will
set the value for isFinal
to false
.
value
- true for abstract.public boolean isFinal()
public void setFinal(boolean value)
Note: Calling this method with true
will
set the value for isAbstract
to false
.
value
- true for final.public boolean isStatic()
public void setStatic(boolean value)
value
- true for static.public boolean isSynchronized()
public void setSynchronized(boolean value)
value
- true for synchronized.public boolean isNative()
public void setNative(boolean value)
value
- true for native.public JavaIdentifier getMethodIdentifier()
public String getPackageName()
public String getType()
public String getName()
protected String getDefaultComment()
JavaFunctionDefinition
getDefaultComment
in class JavaFunctionDefinition
protected boolean hasReturnType()
JavaFunctionDefinition
hasReturnType
in class JavaFunctionDefinition
protected String getReturnComment()
JavaFunctionDefinition
@return
string.
getReturnComment
in class JavaFunctionDefinition
@return
string.public List getImports()
JavaFunctionDefinition
getImports
in class JavaFunctionDefinition
public void writeDefinitionTo(CodeBuffer buffer)
CodeBuffer
.
writeDefinitionTo
in class JavaDefinition
buffer
- The CodeBuffer with which to append the data.CodeBuffer
|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |