| Attributes and methods |
.equalsMethod(EntityInContext entity, int indentationLevel) : String
Returns a string containing all the code for a Java 'equals' method
Generates the method using all the attributes of the given entity
Indentation with TABS (1 tab for each indentation level)
Parameters :
entity : the entity for which to generate the 'equals' method
indentationLevel : initial indentation level
Example :
$java.equalsMethod( $entity, 1 )
Since : 4.3.0
|
.equalsMethod(EntityInContext entity, int indentationLevel, String indentationString) : String
Returns a string containing all the code for a Java 'equals' method
Generates the method using all the attributes of the given entity
Indentation with SPACES (1 'indentationString' for each indentation level)
Parameters :
entity : the entity for which to generate the 'equals' method
indentationLevel : initial indentation level
indentationString : string to use for each indentation (usually N spaces)
Example :
$java.equalsMethod( $entity, 1, ' ' )
Since : 4.3.0
|
.equalsMethod(String className, List attributes) : String
Deprecated.
Returns a string containing all the code for a Java 'equals' method
Tabulations are used for code indentation
(!) DEPRECATED - do not use
Parameters :
className : the Java class name (simple name or full name)
attributes : list of attributes to be used in the equals method
Example :
$java.equalsMethod( $entity.name, $entity.attributes )
Since : 2.0.7
|
.equalsMethod(String className, List attributes, int indentSpaces) : String
Deprecated.
Returns a string containing all the code for a Java 'equals' method
Spaces are used for code indentation
(!) DEPRECATED - do not use
Parameters :
className : the Java class name (simple name or full name)
attributes : list of attributes to be used in the equals method
indentSpaces : number of spaces to be used for each indentation level
Example :
$java.equalsMethod( $entity.name, $entity.attributes, 4 )
Since : 2.0.7
|
.hasValidationAnnotations(AttributeInContext attribute) : boolean
Returns TRUE if the attribute has at least one validation annotation
Useful to avoid a blank line if no annotation
Parameters :
attribute : the attribute to be checked
Example :
#if( $java.hasValidationAnnotations($attribute) )
$java.validationAnnotations(4, $attribute)
#end
Since : 4.3.0
|
.hashCodeMethod(EntityInContext entity, int indentationLevel) : String
Returns a string containing all the code for a Java 'hashCode' method
Generates the method using all the attributes of the given entity
Indentation with TABS (1 tab for each indentation level)
Parameters :
entity : the entity for which to generate the method
indentationLevel : initial indentation level (usually 1)
Example :
$java.hashCodeMethod( $entity, 1 )
Since : 4.3.0
|
.hashCodeMethod(EntityInContext entity, int indentationLevel, String indentationString) : String
Returns a string containing all the code for a Java 'hashCode' method
Generates the method using all the attributes of the given entity
Indentation with SPACES (1 'indentationString' for each indentation level)
Parameters :
entity : the entity for which to generate the method
indentationLevel : initial indentation level (usually 1)
indentationString : string to use for each indentation (usually N spaces)
Example :
$java.hashCodeMethod( $entity, 1, ' ' )
Since : 4.3.0
|
.hashCodeMethod(String className, List attributes) : String
Deprecated.
Returns a string containing all the code for a Java 'hashCode' method
Tabulations are used for code indentation
(!) DEPRECATED - do not use
Parameters :
className : the Java class name (simple name or full name)
attributes : list of attributes to be used in the equals method
Example :
$java.hashCodeMethod( $entity.name, $entity.attributes )
Since : 2.0.7
|
.hashCodeMethod(String className, List attributes, int indentSpaces) : String
Deprecated.
Returns a string containing all the code for a Java 'hashCode' method
Spaces are used for code indentation
(!) DEPRECATED - do not use
Parameters :
className : the Java class name (simple name or full name)
attributes : list of attributes to be used in the equals method
indentSpaces : number of spaces to be used for each indentation level
Example :
$java.hashCodeMethod( $entity.name, $entity.attributes, 4 )
Since : 2.0.7
|
.imports(EntityInContext entity) : List
Returns the list of Java classes to be imported for the given entity
The imports are determined using all the entity attributes and links
Examples for attributes : 'java.time.LocalDateTime', 'java.math.BigDecimal', etc
Examples for links : 'java.util.List', etc
Parameters :
entity : entity to be used
Example :
#foreach( $import in $java.imports($entity) )
import $import;
#end
Since : 2.0.7
|
.imports(List attributes) : List
Returns the list of Java classes to be imported for the given attributes
Parameters :
attributes : list of attributes
Example :
#foreach( $import in $java.imports($entity.attributes) )
import $import;
#end
Since : 2.0.7
|
.toStringMethod(EntityInContext entity, List attributes, int indentationLevel) : String
Returns a string containing all the code for a Java 'toString()' method
Generates a 'toString' method using the given attributes
(except non-printable attributes)
Indent with TABS (1 tab for each indentation level)
Parameters :
entity : the entity for which to generate the 'toString' method
attributes : list of attributes to be used in the 'toString' method
indentationLevel : initial indentation level
Example :
$java.toStringMethod( $entity, $attributes, 2 )
Since : 4.1.0
|
.toStringMethod(EntityInContext entity, List attributes, int indentationLevel, String indentationString) : String
Returns a string containing all the code for a Java 'toString()' method
Generates a 'toString' method using the given attributes
(except non-printable attributes)
Indentation with spaces (1 'indentationString' for each indentation level)
Parameters :
entity : the entity for which to generate the 'toString' method
attributes : list of attributes to be used in the 'toString' method
indentationLevel : initial indentation level
indentationString : string to use for each indentation (usually N spaces)
Example :
$java.toStringMethod( $entity, $attributes, 2, ' ' )
Since : 4.1.0
|
.toStringMethod(EntityInContext entity, int indentationLevel) : String
Returns a string containing all the code for a Java 'toString()' method
Generates a 'toString' method using all the attributes of the given entity
(except non-printable attributes)
Indentation with TABS (1 tab for each indentation level)
Parameters :
entity : the entity for which to generate the 'toString' method
indentationLevel : initial indentation level
Example :
$java.toStringMethod( $entity, 2 )
Since : 4.1.0
|
.toStringMethod(EntityInContext entity, int indentationLevel, String indentationString) : String
Returns a string containing all the code for a Java 'toString()' method
Generates a 'toString' method using all the attributes of the given entity
(except non-printable attributes)
Indentation with SPACES (1 'indentationString' for each indentation level)
Parameters :
entity : the entity for which to generate the 'toString' method
indentationLevel : initial indentation level
indentationString : string to use for each indentation (usually N spaces)
Example :
$java.toStringMethod( $entity, 2, ' ' )
Since : 4.1.0
|
.validationAnnotations(int leftMargin, AttributeInContext attribute) : String
Returns the 'Bean Validation (JSR-303)' or 'Jakarta EE' annotations for the given attribute
All annotations are grouped on a single line
Annotation from packages 'javax.validation.constraints' or 'jakarta.validation.constraints'
For example: @NotNull, @NotBlank, @Size, @Min, @Max, etc
Do not forget to import the package you want to use:
import jakarta.validation.constraints.*;
or import javax.validation.constraints.*;
Parameters :
leftMargin : the left margin size (number of blanks)
attribute : the attribute to be annotated
Example :
$java.validationAnnotations(4, $attribute)
Since : 4.3.0
|
.validationAnnotationsMultiline(int leftMargin, AttributeInContext attribute) : String
Same as 'validationAnnotations' but with multiline result (one line for each annotation)
Parameters :
leftMargin : the left margin size (number of blanks)
attribute : the attribute to be annotated
Example :
$java.validationAnnotationsMultiline(4, $attribute)
Since : 4.3.0
|