|
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.JavaFieldDefinition
This class is used to define the attributes of a Java field. The attributes can then be used to generate a valid Java field definition string.
The number of constructors are meant to make it easy to define a field with as few statements as possible.
If left uninitialized, the access control modifier for the field defaults to package access.
Field Summary | |
protected JavaIdentifier |
field
|
protected JavaAccessModifier |
getterAccessModifier
The getter's access modifier. |
protected String |
initializer
The initializer expression, without the = assignment operator. |
protected boolean |
isFinal
Is the field final? Default = false. |
protected boolean |
isStatic
Is the field static? Default = false. |
protected boolean |
isTransient
Is the field transient? Default = false. |
protected boolean |
isVolatile
Is the field volatile? Default = false. |
protected boolean |
needsGetter
Generate a getter method? Default = false. |
protected boolean |
needsSetter
Generate a setter method? Default = false. |
protected JavaAccessModifier |
setterAccessModifier
The setter's access modifier. |
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 | |
JavaFieldDefinition(JavaIdentifier field)
Constructs a JavaFieldDefinition with the specified
field identifier. |
|
JavaFieldDefinition(JavaIdentifier field,
boolean createGetter,
boolean createSetter)
Constructs a JavaFieldDefinition with the specified
field identifier,
and whether a getter and/or setter should be generated. |
|
JavaFieldDefinition(String comment,
JavaAccessModifier accessModifier,
boolean isStatic,
boolean isFinal,
boolean isTransient,
boolean isVolatile,
JavaIdentifier field,
String initializer,
boolean createGetter,
boolean createSetter,
JavaAccessModifier getterAccessModifier,
JavaAccessModifier setterAccessModifier)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field identifier, initializer,
whether the field is static, final or both,
whether the field is transient, volatile or both,
whether a getter and/or setter should be generated,
and the access control modifiers for the getter and setter. |
|
JavaFieldDefinition(String comment,
JavaAccessModifier accessModifier,
boolean isStatic,
boolean isFinal,
JavaIdentifier field,
String initializer)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field identifier, initializer,
and whether the field is static, final or both. |
|
JavaFieldDefinition(String comment,
JavaAccessModifier accessModifier,
boolean isStatic,
boolean isFinal,
JavaIdentifier field,
String initializer,
boolean createGetter,
boolean createSetter)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field identifier, initializer,
whether the field is static, final or both,
and whether a getter and/or setter should be generated. |
|
JavaFieldDefinition(String comment,
JavaAccessModifier accessModifier,
boolean isStatic,
boolean isFinal,
JavaIdentifier field,
String initializer,
boolean createGetter,
boolean createSetter,
JavaAccessModifier getterAccessModifier,
JavaAccessModifier setterAccessModifier)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field identifier, initializer,
whether the field is static, final or both,
whether a getter and/or setter should be generated,
and the access control modifiers for the getter and setter. |
|
JavaFieldDefinition(String comment,
JavaAccessModifier accessModifier,
JavaIdentifier field)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, and field identifier. |
|
JavaFieldDefinition(String comment,
JavaAccessModifier accessModifier,
JavaIdentifier field,
boolean createGetter,
boolean createSetter)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field identifier,
and whether a getter and/or setter should be generated. |
|
JavaFieldDefinition(String comment,
JavaAccessModifier accessModifier,
JavaIdentifier field,
String initializer)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field identifier, and initializer. |
|
JavaFieldDefinition(String fieldType,
String fieldName)
Constructs a JavaFieldDefinition with the specified
field type, and field name. |
|
JavaFieldDefinition(String fieldType,
String fieldName,
boolean createGetter,
boolean createSetter)
Constructs a JavaFieldDefinition with the specified
field type, field name
and whether a getter and/or setter should be generated. |
|
JavaFieldDefinition(String comment,
String accessModifier,
boolean isStatic,
boolean isFinal,
boolean isTransient,
boolean isVolatile,
String fieldType,
String fieldName,
String initializer,
boolean createGetter,
boolean createSetter,
String getterAccessModifier,
String setterAccessModifier)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field type, field name, initializer,
whether the field is static, final or both,
whether the field is transient, volatile or both,
whether a getter and/or setter should be generated,
and the access control modifiers for the getter and setter. |
|
JavaFieldDefinition(String comment,
String accessModifier,
boolean isStatic,
boolean isFinal,
String fieldType,
String fieldName,
String initializer)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field type, field name, initializer,
and whether the field is static, final or both. |
|
JavaFieldDefinition(String comment,
String accessModifier,
boolean isStatic,
boolean isFinal,
String fieldType,
String fieldName,
String initializer,
boolean createGetter,
boolean createSetter)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field type, field name, initializer,
whether the field is static, final or both,
and whether a getter and/or setter should be generated. |
|
JavaFieldDefinition(String comment,
String accessModifier,
boolean isStatic,
boolean isFinal,
String fieldType,
String fieldName,
String initializer,
boolean createGetter,
boolean createSetter,
String getterAccessModifier,
String setterAccessModifier)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field type, field name, initializer,
whether the field is static, final or both,
whether a getter and/or setter should be generated,
and the access control modifiers for the getter and setter. |
|
JavaFieldDefinition(String comment,
String accessModifier,
String fieldType,
String fieldName)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field type, and field name. |
|
JavaFieldDefinition(String comment,
String accessModifier,
String fieldType,
String fieldName,
boolean createGetter,
boolean createSetter)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field type, field name
and whether a getter and/or setter should be generated. |
|
JavaFieldDefinition(String comment,
String accessModifier,
String fieldType,
String fieldName,
String initializer)
Constructs a JavaFieldDefinition with the specified
comment, access control modifier, field type, field name, and initializer. |
Method Summary | |
int |
getArrayDimension()
Returns how many dimensions the array has, assuming the field is an array. |
JavaIdentifier |
getField()
Returns the field's identifier. |
String |
getGetter()
Returns a String containing the Java source representation of the getter. |
JavaAccessModifier |
getGetterAccessModifier()
Returns the access control modifier for the getter. |
List |
getImports()
Returns a list of potential import types for the field. |
String |
getInitializer()
Returns the field's initializer. |
String |
getName()
Returns the field's name. |
String |
getPackageName()
Returns the field's package name. |
String |
getSetter()
Returns a String containing the Java source representation of the setter. |
JavaAccessModifier |
getSetterAccessModifier()
Returns the access control modifier for the setter. |
String |
getType()
Returns the field's type. |
boolean |
isArray()
Returns whether the field is an array or not. |
boolean |
isFinal()
Returns whether the field is final or not. |
boolean |
isStatic()
Returns whether the field is static or not. |
boolean |
isTransient()
Returns whether the field is transient or not. |
boolean |
isVolatile()
Returns whether the field is volatile or not. |
boolean |
needsGetter()
Returns whether a getter method should be generated to access the field. |
void |
needsGetter(boolean value)
Set whether a getter method should be generated to access the field. |
boolean |
needsSetter()
Returns whether a setter method should be generated to access the field. |
void |
needsSetter(boolean value)
Set whether a setter method should be generated to access the field. |
void |
setFinal(boolean value)
Set whether the field is final or not. |
void |
setInitializer(String newInitializer)
Set the field's initializer. |
void |
setStatic(boolean value)
Set whether the field is static or not. |
void |
setTransient(boolean value)
Set whether the field is transient or not. |
void |
setVolatile(boolean value)
Set whether the field is volatile or not. |
void |
writeDefinitionTo(CodeBuffer buffer)
Write the Java source representation of the field to the CodeBuffer . |
void |
writeGetterTo(CodeBuffer buffer)
Write the Java source representation of the getter to the CodeBuffer . |
void |
writeSetterTo(CodeBuffer buffer)
Write the Java source representation of the setter to the CodeBuffer . |
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 isStatic
protected boolean isFinal
protected boolean isTransient
protected boolean isVolatile
protected JavaIdentifier field
protected String initializer
protected boolean needsGetter
protected boolean needsSetter
protected JavaAccessModifier getterAccessModifier
protected JavaAccessModifier setterAccessModifier
Constructor Detail |
public JavaFieldDefinition(String fieldType, String fieldName)
JavaFieldDefinition
with the specified
field type, and field name.
fieldType
- The field's type.fieldName
- The field's name.public JavaFieldDefinition(JavaIdentifier field)
JavaFieldDefinition
with the specified
field identifier.
field
- The field's identifier.public JavaFieldDefinition(String fieldType, String fieldName, boolean createGetter, boolean createSetter)
JavaFieldDefinition
with the specified
field type, field name
and whether a getter and/or setter should be generated.
fieldType
- The field's type.fieldName
- The field's name.createGetter
- true if a getter should be generated.createSetter
- true if a setter should be generated.public JavaFieldDefinition(JavaIdentifier field, boolean createGetter, boolean createSetter)
JavaFieldDefinition
with the specified
field identifier,
and whether a getter and/or setter should be generated.
field
- The field's identifier.createGetter
- true if a getter should be generated.createSetter
- true if a setter should be generated.public JavaFieldDefinition(String comment, String accessModifier, String fieldType, String fieldName)
JavaFieldDefinition
with the specified
comment, access control modifier, field type, and field name.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.fieldType
- The field's type.fieldName
- The field's name.public JavaFieldDefinition(String comment, JavaAccessModifier accessModifier, JavaIdentifier field)
JavaFieldDefinition
with the specified
comment, access control modifier, and field identifier.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.field
- The field's identifier.public JavaFieldDefinition(String comment, String accessModifier, String fieldType, String fieldName, boolean createGetter, boolean createSetter)
JavaFieldDefinition
with the specified
comment, access control modifier, field type, field name
and whether a getter and/or setter should be generated.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.fieldType
- The field's type.fieldName
- The field's name.createGetter
- true if a getter should be generated.createSetter
- true if a setter should be generated.public JavaFieldDefinition(String comment, JavaAccessModifier accessModifier, JavaIdentifier field, boolean createGetter, boolean createSetter)
JavaFieldDefinition
with the specified
comment, access control modifier, field identifier,
and whether a getter and/or setter should be generated.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.field
- The field's identifier.createGetter
- true if a getter should be generated.createSetter
- true if a setter should be generated.public JavaFieldDefinition(String comment, String accessModifier, String fieldType, String fieldName, String initializer)
JavaFieldDefinition
with the specified
comment, access control modifier, field type, field name, and initializer.
Do not include the = sign (assignment operator) in the initializer.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.fieldType
- The field's type.fieldName
- The field's name.initializer
- The field's initializer string.public JavaFieldDefinition(String comment, JavaAccessModifier accessModifier, JavaIdentifier field, String initializer)
JavaFieldDefinition
with the specified
comment, access control modifier, field identifier, and initializer.
Do not include the = sign (assignment operator) in the initializer.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.field
- The field's identifier.initializer
- The field's initializer string.public JavaFieldDefinition(String comment, String accessModifier, boolean isStatic, boolean isFinal, String fieldType, String fieldName, String initializer)
JavaFieldDefinition
with the specified
comment, access control modifier, field type, field name, initializer,
and whether the field is static, final or both.
Do not include the = sign (assignment operator) in the initializer.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.isStatic
- true if the field is defined to be static.isFinal
- true if the field is defined to be final.fieldType
- The field's type.fieldName
- The field's name.initializer
- The field's initializer string.public JavaFieldDefinition(String comment, JavaAccessModifier accessModifier, boolean isStatic, boolean isFinal, JavaIdentifier field, String initializer)
JavaFieldDefinition
with the specified
comment, access control modifier, field identifier, initializer,
and whether the field is static, final or both.
Do not include the = sign (assignment operator) in the initializer.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.isStatic
- true if the field is defined to be static.isFinal
- true if the field is defined to be final.field
- The field's identifier.initializer
- The field's initializer string.public JavaFieldDefinition(String comment, String accessModifier, boolean isStatic, boolean isFinal, String fieldType, String fieldName, String initializer, boolean createGetter, boolean createSetter)
JavaFieldDefinition
with the specified
comment, access control modifier, field type, field name, initializer,
whether the field is static, final or both,
and whether a getter and/or setter should be generated.
Do not include the = sign (assignment operator) in the initializer.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.isStatic
- true if the field is defined to be static.isFinal
- true if the field is defined to be final.fieldType
- The field's type.fieldName
- The field's name.initializer
- The field's initializer string.createGetter
- true if a getter should be generated.createSetter
- true if a setter should be generated.public JavaFieldDefinition(String comment, JavaAccessModifier accessModifier, boolean isStatic, boolean isFinal, JavaIdentifier field, String initializer, boolean createGetter, boolean createSetter)
JavaFieldDefinition
with the specified
comment, access control modifier, field identifier, initializer,
whether the field is static, final or both,
and whether a getter and/or setter should be generated.
Do not include the = sign (assignment operator) in the initializer.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.isStatic
- true if the field is defined to be static.isFinal
- true if the field is defined to be final.field
- The field's identifier.initializer
- The field's initializer string.createGetter
- true if a getter should be generated.createSetter
- true if a setter should be generated.public JavaFieldDefinition(String comment, String accessModifier, boolean isStatic, boolean isFinal, String fieldType, String fieldName, String initializer, boolean createGetter, boolean createSetter, String getterAccessModifier, String setterAccessModifier)
JavaFieldDefinition
with the specified
comment, access control modifier, field type, field name, initializer,
whether the field is static, final or both,
whether a getter and/or setter should be generated,
and the access control modifiers for the getter and setter.
Do not include the = sign (assignment operator) in the initializer.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.isStatic
- true if the field is defined to be static.isFinal
- true if the field is defined to be final.fieldType
- The field's type.fieldName
- The field's name.initializer
- The field's initializer string.createGetter
- true if a getter should be generated.createSetter
- true if a setter should be generated.getterAccessModifier
- The getter's access control modifier.setterAccessModifier
- The setter's access control modifier.public JavaFieldDefinition(String comment, JavaAccessModifier accessModifier, boolean isStatic, boolean isFinal, JavaIdentifier field, String initializer, boolean createGetter, boolean createSetter, JavaAccessModifier getterAccessModifier, JavaAccessModifier setterAccessModifier)
JavaFieldDefinition
with the specified
comment, access control modifier, field identifier, initializer,
whether the field is static, final or both,
whether a getter and/or setter should be generated,
and the access control modifiers for the getter and setter.
Do not include the = sign (assignment operator) in the initializer.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.isStatic
- true if the field is defined to be static.isFinal
- true if the field is defined to be final.field
- The field's identifier.initializer
- The field's initializer string.createGetter
- true if a getter should be generated.createSetter
- true if a setter should be generated.getterAccessModifier
- The getter's access control modifier.setterAccessModifier
- The setter's access control modifier.public JavaFieldDefinition(String comment, String accessModifier, boolean isStatic, boolean isFinal, boolean isTransient, boolean isVolatile, String fieldType, String fieldName, String initializer, boolean createGetter, boolean createSetter, String getterAccessModifier, String setterAccessModifier)
JavaFieldDefinition
with the specified
comment, access control modifier, field type, field name, initializer,
whether the field is static, final or both,
whether the field is transient, volatile or both,
whether a getter and/or setter should be generated,
and the access control modifiers for the getter and setter.
Do not include the = sign (assignment operator) in the initializer.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.isStatic
- true if the field is defined to be static.isFinal
- true if the field is defined to be final.fieldType
- The field's type.fieldName
- The field's name.initializer
- The field's initializer string.createGetter
- true if a getter should be generated.createSetter
- true if a setter should be generated.getterAccessModifier
- The getter's access control modifier.setterAccessModifier
- The setter's access control modifier.public JavaFieldDefinition(String comment, JavaAccessModifier accessModifier, boolean isStatic, boolean isFinal, boolean isTransient, boolean isVolatile, JavaIdentifier field, String initializer, boolean createGetter, boolean createSetter, JavaAccessModifier getterAccessModifier, JavaAccessModifier setterAccessModifier)
JavaFieldDefinition
with the specified
comment, access control modifier, field identifier, initializer,
whether the field is static, final or both,
whether the field is transient, volatile or both,
whether a getter and/or setter should be generated,
and the access control modifiers for the getter and setter.
Do not include the = sign (assignment operator) in the initializer.
comment
- The field's descriptive comment.accessModifier
- The field's access control modifier.isStatic
- true if the field is defined to be static.isFinal
- true if the field is defined to be final.field
- The field's identifier.initializer
- The field's initializer string.createGetter
- true if a getter should be generated.createSetter
- true if a setter should be generated.getterAccessModifier
- The getter's access control modifier.setterAccessModifier
- The setter's access control modifier.Method Detail |
public boolean isStatic()
public void setStatic(boolean value)
value
- true for static.public boolean isFinal()
public void setFinal(boolean value)
value
- true for final.public boolean isTransient()
public void setTransient(boolean value)
value
- true for transient.public boolean isVolatile()
public void setVolatile(boolean value)
value
- true for volatile.public JavaIdentifier getField()
public String getPackageName()
public String getType()
public String getName()
public boolean isArray()
getArrayDimension()
public int getArrayDimension()
isArray()
public String getInitializer()
public void setInitializer(String newInitializer)
newInitializer
- The field's initializer.public boolean needsGetter()
public void needsGetter(boolean value)
value
- true if a getter method should be generated.public boolean needsSetter()
public void needsSetter(boolean value)
value
- true if a setter method should be generated.public JavaAccessModifier getGetterAccessModifier()
needsGetter
public JavaAccessModifier getSetterAccessModifier()
needsSetter
public void writeDefinitionTo(CodeBuffer buffer)
CodeBuffer
.
writeDefinitionTo
in class JavaDefinition
buffer
- The CodeBuffer with which to append the data.CodeBuffer
public String getGetter()
public void writeGetterTo(CodeBuffer buffer)
CodeBuffer
.
buffer
- The CodeBuffer with which to append the data.CodeBuffer
public String getSetter()
public void writeSetterTo(CodeBuffer buffer)
CodeBuffer
.
buffer
- The CodeBuffer with which to append the data.CodeBuffer
public List getImports()
getImports
in class JavaDefinition
|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |