|
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.JavaConstructorDefinition
This class is used to define the attributes of a Java constructor method. The attributes can then be used to generate a valid Java constructor method definition string.
The number of constructors are meant to make it easy to define a constructor with as few statements as possible. There are also additional shortcut static methods to create a default constructor.
If left uninitialized, the access control modifier for the constructor defaults to public access.
Field Summary | |
protected String |
className
The class name for this constructor. |
static String |
DEFAULT_CODE_BLOCK
The code block to use for the default constructor. |
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 | |
JavaConstructorDefinition(String comment,
JavaAccessModifier accessModifier,
String className,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaConstructorDefinition with the specified
comment, access control modifier, class name, list of formal parameters,
list of thrown exceptions, and code block. |
|
JavaConstructorDefinition(String comment,
JavaAccessModifier accessModifier,
String className,
List parameters,
String codeBlock)
Constructs a JavaConstructorDefinition with the specified
comment, access control modifier, class name, list of formal parameters,
and code block. |
|
JavaConstructorDefinition(String comment,
JavaAccessModifier accessModifier,
String className,
String codeBlock)
Constructs a JavaConstructorDefinition with the specified
comment, access control modifier, class name, and code block. |
|
JavaConstructorDefinition(String className,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaConstructorDefinition with the specified
class name, list of formal parameters,
list of thrown exceptions, and code block. |
|
JavaConstructorDefinition(String className,
List parameters,
String codeBlock)
Constructs a JavaConstructorDefinition with the specified
class name, list of formal parameters, and code block. |
|
JavaConstructorDefinition(String className,
String codeBlock)
Constructs a JavaConstructorDefinition with the specified
class name and code block. |
|
JavaConstructorDefinition(String comment,
String accessModifier,
String className,
List parameters,
List exceptions,
String codeBlock)
Constructs a JavaConstructorDefinition with the specified
comment, access control modifier, class name, list of formal parameters,
list of thrown exceptions, and code block. |
|
JavaConstructorDefinition(String comment,
String accessModifier,
String className,
List parameters,
String codeBlock)
Constructs a JavaConstructorDefinition with the specified
comment, access control modifier, class name, list of formal parameters,
and code block. |
|
JavaConstructorDefinition(String comment,
String accessModifier,
String className,
String codeBlock)
Constructs a JavaConstructorDefinition with the specified
comment, access control modifier, class name, and code block. |
Method Summary | |
static JavaConstructorDefinition |
defaultConstructorFor(String className)
Create a new default constructor with the specified class name. |
static JavaConstructorDefinition |
defaultConstructorFor(String comment,
JavaAccessModifier accessModifier,
String className)
Create a new default constructor with the specified comment, access control modifier, and class name. |
static JavaConstructorDefinition |
defaultConstructorFor(String comment,
JavaAccessModifier accessModifier,
String className,
String codeBlock)
Create a new default constructor with the specified comment, access control modifier, class name, and code block. |
static JavaConstructorDefinition |
defaultConstructorFor(String className,
String codeBlock)
Create a new default constructor with the specified class name and code block. |
static JavaConstructorDefinition |
defaultConstructorFor(String comment,
String accessModifier,
String className)
Create a new default constructor with the specified comment, access control modifier, and class name. |
static JavaConstructorDefinition |
defaultConstructorFor(String comment,
String accessModifier,
String className,
String codeBlock)
Create a new default constructor with the specified comment, access control modifier, class name, and code block. |
String |
getClassName()
Returns the constructor's class name. |
protected String |
getDefaultComment()
Returns a simple, descriptive, one line comment for the function. |
protected String |
getReturnComment()
Returns a javadoc @return string. |
protected boolean |
hasReturnType()
Returns whether the function has a return type or not. |
void |
writeDefinitionTo(CodeBuffer buffer)
Write the Java source representation of the constructor to the CodeBuffer . |
Methods inherited from class org.arch4j.generator.JavaFunctionDefinition |
addException, addException, addExceptions, addParameter, addParameter, addParameter, addParameters, getCodeBlock, getExceptions, getFormattedComment, getImports, 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 |
public static final String DEFAULT_CODE_BLOCK
protected String className
Constructor Detail |
public JavaConstructorDefinition(String className, String codeBlock)
JavaConstructorDefinition
with the specified
class 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.
The access control modifier defaults to public access.
className
- The class name, which is the same as the constructor name.codeBlock
- The statements defining the body of the constructor.public JavaConstructorDefinition(String className, List parameters, String codeBlock)
JavaConstructorDefinition
with the specified
class 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.
The access control modifier defaults to public access.
className
- The class name, which is the same as the constructor name.parameters
- The list of formal parameters the constructor accepts.codeBlock
- The statements defining the body of the constructor.public JavaConstructorDefinition(String className, List parameters, List exceptions, String codeBlock)
JavaConstructorDefinition
with the specified
class 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.
The access control modifier defaults to public access.
className
- The class name, which is the same as the constructor name.parameters
- The list of formal parameters the constructor accepts.exceptions
- The list of exceptions thrown by the constructor.codeBlock
- The statements defining the body of the constructor.public JavaConstructorDefinition(String comment, String accessModifier, String className, String codeBlock)
JavaConstructorDefinition
with the specified
comment, access control modifier, class 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 constructor's descriptive comment.accessModifier
- The constructor's access control modifier.className
- The class name, which is the same as the constructor name.codeBlock
- The statements defining the body of the constructor.public JavaConstructorDefinition(String comment, JavaAccessModifier accessModifier, String className, String codeBlock)
JavaConstructorDefinition
with the specified
comment, access control modifier, class 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 constructor's descriptive comment.accessModifier
- The constructor's access control modifier.className
- The class name, which is the same as the constructor name.codeBlock
- The statements defining the body of the constructor.public JavaConstructorDefinition(String comment, String accessModifier, String className, List parameters, String codeBlock)
JavaConstructorDefinition
with the specified
comment, access control modifier, class 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 constructor's descriptive comment.accessModifier
- The constructor's access control modifier.className
- The class name, which is the same as the constructor name.parameters
- The list of formal parameters the constructor accepts.codeBlock
- The statements defining the body of the constructor.public JavaConstructorDefinition(String comment, JavaAccessModifier accessModifier, String className, List parameters, String codeBlock)
JavaConstructorDefinition
with the specified
comment, access control modifier, class 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 constructor's descriptive comment.accessModifier
- The constructor's access control modifier.className
- The class name, which is the same as the constructor name.parameters
- The list of formal parameters the constructor accepts.codeBlock
- The statements defining the body of the constructor.public JavaConstructorDefinition(String comment, String accessModifier, String className, List parameters, List exceptions, String codeBlock)
JavaConstructorDefinition
with the specified
comment, access control modifier, class 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 constructor's descriptive comment.accessModifier
- The constructor's access control modifier.className
- The class name, which is the same as the constructor name.parameters
- The list of formal parameters the constructor accepts.exceptions
- The list of exceptions thrown by the constructor.codeBlock
- The statements defining the body of the constructor.public JavaConstructorDefinition(String comment, JavaAccessModifier accessModifier, String className, List parameters, List exceptions, String codeBlock)
JavaConstructorDefinition
with the specified
comment, access control modifier, class 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 constructor's descriptive comment.accessModifier
- The constructor's access control modifier.className
- The class name, which is the same as the constructor name.parameters
- The list of formal parameters the constructor accepts.exceptions
- The list of exceptions thrown by the constructor.codeBlock
- The statements defining the body of the constructor.Method Detail |
public static JavaConstructorDefinition defaultConstructorFor(String className)
className
- The class name, which is the same as the constructor name.public static JavaConstructorDefinition defaultConstructorFor(String className, String codeBlock)
CodeBuffer
. Create it with an initial indentation level of zero.
className
- The class name, which is the same as the constructor name.codeBlock
- The statements defining the body of the constructor.public static JavaConstructorDefinition defaultConstructorFor(String comment, String accessModifier, String className)
comment
- The constructor's descriptive comment.accessModifier
- The constructor's access control modifier.className
- The class name, which is the same as the constructor name.public static JavaConstructorDefinition defaultConstructorFor(String comment, JavaAccessModifier accessModifier, String className)
comment
- The constructor's descriptive comment.accessModifier
- The constructor's access control modifier.className
- The class name, which is the same as the constructor name.public static JavaConstructorDefinition defaultConstructorFor(String comment, String accessModifier, String className, String codeBlock)
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The constructor's descriptive comment.accessModifier
- The constructor's access control modifier.className
- The class name, which is the same as the constructor name.codeBlock
- The statements defining the body of the constructor.public static JavaConstructorDefinition defaultConstructorFor(String comment, JavaAccessModifier accessModifier, String className, String codeBlock)
CodeBuffer
. Create it with an initial indentation level of zero.
comment
- The constructor's descriptive comment.accessModifier
- The constructor's access control modifier.className
- The class name, which is the same as the constructor name.codeBlock
- The statements defining the body of the constructor.public String getClassName()
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 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 |