$attribute

Other name(s) : $attrib$attr

( documentation for Telosys generator version 4.1.0 )


This object provides all information about an entity attribute
Each attribute is obtained from its entity class


Example :
   
   #foreach( $attribute in $entity.attributes )
    $attribute.name : $attribute.type
   #end

Since : 2.0.0

Attributes and methods
.booleanFalseValue : String

Returns the value to use for a boolean when is FALSE (eg to be stored in a database)

.booleanTrueValue : String

Returns the value to use for a boolean when is TRUE (eg to be stored in a database)

.databaseComment : String

Returns the database comment for the attribute (or a void string if none)

Since : 2.1.1

.databaseDefaultValue : String

Returns the database default value for the attribute (or a void string if none)

.databaseName : String

Returns the database name for the attribute (as defined in the model)
or an empty string if none
Typically the column name for a relational database

.databaseSize : String

Returns the database size for the attribute
(for example : '45' or '10,2' for precision with scale)
or an empty string if none
Try to get the size from the 'database type' first
if not found return the standard size if any

.databaseType : String

Returns the database native type for the attribute (as defined in the model)
or an empty string if none
For example : INTEGER, VARCHAR, etc...

.dateAfterValue : String

Returns the 'date after' value (for date validation)
(returns a void string if none)

.dateBeforeValue : String

Returns the 'date before' value (for date validation)
(returns a void string if none)

.defaultValue : String

Returns the default value for the attribute
(returns a void string if none)

.entity : EntityInContext

Returns the entity owning the attribute

.fkParts : List of 'fkPart' objects

Returns all the parts of Foreign Keys in which the attribute is involved.
Each 'FK part' provides the referenced entity and attribute.
An empty list is returned if the attribute does not participate in any FK.

Example :
   #foreach( $fkPart in $attribute.fkParts )
   ...
   #end

Since : 3.3.0

.fkPartsCount : int

Returns the number of FK parts in which the attribute is involved.

Example :
   $attribute.fkPartsCount

Since : 4.1.0

.formattedName(int n) : String

Returns the attribute's name with trailing blanks in order to obtain the expected size

Parameters :
   n : the expected size

.formattedType(int n) : String

Returns the attribute's type with trailing blanks in order to obtain the expected size

Parameters :
   n : the expected size

.formattedWrapperType(int n) : String

Returns the attribute's wrapper type with trailing blanks in order to obtain the expected size

Parameters :
   n : the expected size

.fullType : String

Returns the full type name
e.g. for a Java object type : java.math.BigDecimal, java.util.Date, ..
or for a Java primitive type : short, int, ..

.generatedValueAllocationSize : int

Returns the generated value allocation size usable in ORM like JPA or Doctrine (or 0 if not defined)
Can be used for JPA '@SequenceGenerator allocationSize' or '@TableGenerator allocationSize'

Example :
   #if ( $attribute.hasGeneratedValueAllocationSize() )
   Generated value allocation size is $attribute.generatedValueAllocationSize
   #end

Since : 4.1.0

.generatedValueInitialValue : int

Returns the generated value initial value usable in ORM like JPA or Doctrine (or 0 if not defined)
Typically for JPA '@SequenceGenerator initialValue' or '@TableGenerator initialValue'

Example :
   #if ( $attribute.hasGeneratedValueInitialValue() )
   Generated value initial value is $attribute.generatedValueInitialValue
   #end

Since : 4.1.0

.generatedValueSequenceName : String

Returns the 'sequence name' to use for a generated value (or a void string if none)
Typically for JPA '@SequenceGenerator/sequenceName'

Example :
   #if ( $attribute.hasGeneratedValueSequenceName() )
   Generated value sequence name is $attribute.generatedValueSequenceName
   #end

Since : 4.1.0

.generatedValueStrategy : String

Returns the generated value strategy if any.
The returned strategy can be 'AUTO', 'IDENTITY', 'SEQUENCE', 'TABLE' (or '' if none)
Useful for ORM like JPA or Doctrine

.generatedValueTablePkValue : String

Returns the primary key (string value) that identifies the generated value in the table
useful for ORM like JPA or Doctrine
Returns a void string if none

Example :
   #if ( $attribute.hasGeneratedValueTablePkValue() )
   Generated value : PK value in table is $attribute.generatedValueTablePkValue
   #end

Since : 4.1.0

.getter : String

Returns the getter for the attribute
e.g : 'getFoo' for 'foo' (or 'isFoo' for a boolean primitive type)

.getterWithGetPrefix : String

Returns the getter for the attribute with always a 'get' prefix
even for a boolean

.hasDatabaseComment() : boolean

Returns TRUE if the attribute has a database comment defined in the model
(database comment not null and not void)

Example :
   #if ( $attribute.hasDatabaseComment() )
   ...
   #end

Since : 3.3.0

.hasDatabaseDefaultValue() : boolean

Returns TRUE if the attribute has a database default value
(database default value not null and not void)
If the attribute is 'auto-incremented' then always returns false

Example :
   #if ( $attribute.hasDatabaseDefaultValue() )
   ...
   #end

.hasDatabaseName() : boolean

Returns TRUE if the attribute has a database name explicitly defined in the model
(database name not null and not void)

Example :
   #if ( $attribute.hasDatabaseName() )
   ...
   #end

Since : 3.4.0

.hasDatabaseType() : boolean

Returns TRUE if the attribute has a database type explicitly defined in the model
(database type not null and not void)

Example :
   #if ( $attribute.hasDatabaseType() )
   ...
   #end

Since : 3.4.0

.hasDateAfterValidation() : boolean

Returns TRUE if the attribute must be validated as a date AFTER a given date value

.hasDateBeforeValidation() : boolean

Returns TRUE if the attribute must be validated as a date BEFORE a given date value

.hasDateFutureValidation() : boolean

Returns TRUE if the attribute must be validated as a date in the future

.hasDatePastValidation() : boolean

Returns TRUE if the attribute must be validated as a date in the past

.hasDefaultValue() : boolean

Returns TRUE if there's a default value for the attribute (not void)

.hasGeneratedValueAllocationSize() : boolean

Returns true if the attribute has a generated value allocation size

Example :
   #if ( $attribute.hasGeneratedValueAllocationSize() )

Since : 4.1.0

.hasGeneratedValueInitialValue() : boolean

Returns true if the attribute has an initial value for the generated value

Example :
   #if ( $attribute.hasGeneratedValueInitialValue() )

Since : 4.1.0

.hasGeneratedValueSequenceName() : boolean

Returns true if the attribute has a sequence name for the generated value

Example :
   #if ( $attribute.hasGeneratedValueSequenceName() )

Since : 4.1.0

.hasGeneratedValueStrategy(String strategyName) : boolean

Returns TRUE if the attribute has a generated value strategy equal to the given name
(strategy name comparison is not case sensitive)

Parameters :
   strategyName : can be 'AUTO', 'IDENTITY', 'SEQUENCE', 'TABLE'

Example :
   #if ( $attribute.hasGeneratedValueStrategy('SEQUENCE') )

Since : 4.1.0

.hasGeneratedValueTablePkValue() : boolean

Returns true if the attribute has a primary key that identifies the generated value in the table

Example :
   #if ( $attribute.hasGeneratedValueTablePkValue() )

Since : 4.1.0

.hasInitialValue() : boolean

Returns TRUE if there's an initial value for the attribute (not void)

.hasInputType() : boolean

Returns TRUE if there's an 'input type' defined for the attribute (not void)

Since : 3.3.0

.hasLabel() : boolean

Returns TRUE if there's an 'label' defined for the attribute (not void)

Since : 3.3.0

.hasTag(String tagName) : boolean

Returns TRUE if the attribute has a tag with the given name

Parameters :
   tagName : name of the tag for which to check the existence

Example :
   $attrib.hasTag('mytag')

Since : 3.3.0

.ini : String

Returns the initialization value for the current language
Usable to initialize the attribute according with the current target language
The 'initial value' is used if defined in the model

Example :
    $attribute.type $attribute.name = $attribute.ini ;

Since : 4.1.0 (experimental)

.initialValue : String

Returns the initial value as is

.inputType : String

Returns the 'input type' defined for the attribute
Typically for HTML 5 : 'number', 'date', ...

Since : 2.0.3

.insertable : String

Returns the 'insertable' flag value as string
( 'true' or 'false' or 'undefined' )

Since : 3.3.0

.insertableIs(boolean value) : boolean

Returns true if 'insertable' flag equals the given value
The flag can be 'undefined' then then neither true nor false

Parameters :
   value : the boolean value

Since : 3.3.0

.isAutoIncremented() : boolean

Returns TRUE if the attribute is 'auto-incremented' by the database
when a new entity is inserted in the database

.isBinaryType() : boolean

Returns TRUE if the attribute's neutral type is 'binary'

Since : 3.0.0

.isBooleanType() : boolean

Returns TRUE if the attribute's neutral type is'boolean'

Since : 2.0.7

.isByteType() : boolean

Returns TRUE if the attribute's neutral type is 'byte'

Since : 2.0.7

.isDatabaseNotNull() : boolean

Returns TRUE if the attribute must be NOT NULL

(!) DEPRECATED : use 'isNotNull()' instead

.isDateType() : boolean

Returns TRUE if the attribute's neutral type is 'date'

Since : 3.0.0

.isDecimalType() : boolean

Returns TRUE if the attribute's neutral type is 'decimal'

Since : 3.0.0

.isDoubleType() : boolean

Returns TRUE if the attribute's neutral type is 'double'

Since : 2.0.7

.isFK() : boolean

Returns TRUE if the attribute is used in at least one Foreign Key
( it can be a 'Simple FK' or a 'Composite FK' or several FK of any type )

Since : 3.0.0

.isFKComposite() : boolean

Returns TRUE if the attribute is used in at least one 'Composite Foreign Key'
( 'Composite FK' means the FK is based on many attributes including this attribute )

Since : 3.0.0

.isFKSimple() : boolean

Returns TRUE if the attribute is used in at least one 'Simple Foreign Key'
( 'Simple FK' means the FK is based only on this attribute )

Since : 3.0.0

.isFloatType() : boolean

Returns TRUE if the attribute's neutral type is 'float'

Since : 2.0.7

.isGeneratedValue() : boolean

Returns TRUE if the attribute's value is generated when a new entity is inserted in the database
It can be generated by the database ('auto-incremented')
or generated by the persistence layer (typically by JPA)

.isIntegerType() : boolean

Returns TRUE if the attribute's neutral type is 'int'

Since : 2.0.7

.isKeyElement() : boolean

Returns TRUE if the attribute is the Primary Key or a part of the Primary Key in the database

.isLongText() : boolean

Returns TRUE if the attribute is a 'Long Text'
i.e. that cannot be transported in a classical string
Typically a text stored as a CLOB or a BLOB

.isLongType() : boolean

Returns TRUE if the attribute's neutral type is 'long'

Since : 2.0.7

.isNotBlank() : boolean

Returns TRUE if the attribute has a 'Not Blank' validation rule

.isNotEmpty() : boolean

Returns TRUE if the attribute has a 'Not Empty' validation rule

.isNotNull() : boolean

Returns TRUE if the attribute has a 'Not Null' validation rule

.isNumberType() : boolean

Returns TRUE if the attribute's neutral type is a number type
( byte, short, int, long, decimal, float, double )

Since : 2.0.7

.isPrimitiveType() : boolean

Returns TRUE if the attribute's language type is a primitive type
i.e. for Java : int, float, boolean, ...

.isShortType() : boolean

Returns TRUE if the attribute's neutral type is 'short'

Since : 2.0.7

.isStringType() : boolean

Returns TRUE if the attribute's neutral type is 'string'

Since : 2.0.7

.isTemporalType() : boolean

Returns TRUE if the attribute's neutral type is a temporal type
( date, time, timestamp )

Since : 2.0.7

.isTimeType() : boolean

Returns TRUE if the attribute's neutral type is 'time'

Since : 3.0.0

.isTimestampType() : boolean

Returns TRUE if the attribute's neutral type is 'timestamp'

Since : 3.0.0

.isTransient() : boolean

Returns TRUE if the attribute is marked as 'transient'

Since : 3.3.0

.isUnique() : boolean

Returns TRUE if the attribute is 'unique'

Since : 3.4.0

.label : String

Returns the label for the attribute
(returns a void string if none)

.maxLength : String

Returns the maximum length for the attribute
(returns a void string if none)

.maxValue : String

Returns the maximum value for the attribute
(returns a void string if none)

.minLength : String

Returns the minimum length for the attribute
(returns a void string if none)

.minValue : String

Returns the minimum value for the attribute
(returns a void string if none)

.name : String

Returns the name of the attribute

.neutralType : String

Returns the 'neutral type', that is to say the type as defined in the model
e.g. : 'string', 'short', 'decimal', 'boolean', 'date', 'time', etc

.pattern : String

Returns the Reg Exp pattern defined for the attribute
(returns a void string if none)

.referencedEntity : EntityInContext

Returns the entity referenced by this attribute (if any)
Can be used only if the attribute 'isFK'
Throws an exception if no entity is refrerenced by the attribute

Since : 3.0.0

.referencedEntityName : String

Returns the name (class name) of the entity referenced by this attribute (if any)
Can be used only if the attribute 'isFK'
Throws an exception if no entity is refrerenced by the attribute

Since : 3.0.0

.setter : String

Returns the setter for the attribute
e.g : 'setFoo' for 'foo'

.simpleType : String

Returns the simple type name
e.g. for a Java object type : BigDecimal, Date, Integer, ..
or for a Java primitive type : short, int, ..

.size : String

Returns the attribute size if any.
Try to get the 'explicit size' first
if no 'explicit size' try to get the 'maximum length'.
The size is returned as a string containing the size as defined in the model
for example : '45' or '10,2' for precision with scale
Returns an empty string if no size

Since : 3.4.0

.sizeAsDecimal : BigDecimal

Returns the attribute size as decimal value (BigDecimal)
(same behavior as 'size' but with conversion to decimal )
Returns 0 if no size
If the size has a scale it is converted to 'precision.scale'
for example : 10.2 for '10,2'

Since : 3.4.0

.sqlColumnConstraints : String

Returns the SQL column constraints for the attribute
For example : NOT NULL DEFAULT 12


Since : 3.4.0

.sqlColumnName : String

Returns the SQL database column name for the attribute
For example 'city_code' for an attribute named 'cityCode'
The database name defined in the model is used in priority
if no database name is defined then the attribute name is converted to database name
by applying the target database conventions (defined in $env)


Since : 3.4.0

.sqlColumnType : String

Returns the SQL database column type for the attribute
For example 'varchar(12)' for an attribute with neutral type 'string'
The database type defined in the model is used in priority
if no database type is defined then the neutral type is converted to database type
by applying the target database conventions (defined in $env)


Since : 3.4.0

.tagValue(String tagName) : String

Returns the value held by the given tag name
If the tag is undefined or has no value, the returned value is an empty string

Parameters :
   tagName : name of the tag for which to get the value

Example :
   $attrib.tagValue('mytag')

Since : 3.3.0

.tagValue(String tagName, String defaultValue) : String

Returns the value held by the given tag name
If the tag is undefined or has no value, the default value is returned

Parameters :
   tagName : name of the tag for which to get the value
   defaultValue : default value if no tag or no value

Example :
   $attrib.tagValue('mytag', 'abc')

Since : 3.4.0

.tagValueAsBoolean(String tagName, boolean defaultValue) : boolean

Returns the boolean value held by the given tag name
If the tag is undefined or has no value, the default value is returned

Parameters :
   tagName : name of the tag for which to get the value
   defaultValue : default value if no tag or no value

Example :
   $attrib.tagValueAsBoolean('mytag', false)

Since : 3.4.0

.tagValueAsInt(String tagName, int defaultValue) : int

Returns the integer value held by the given tag name
If the tag is undefined or has no value, the default value is returned

Parameters :
   tagName : name of the tag for which to get the value
   defaultValue : default value if no tag or no value

Example :
   $attrib.tagValueAsInt('mytag', 123)

Since : 3.4.0

.type : String

Returns the target language type for the attribute
Examples for Java : 'int', 'BigDecimal', 'LocalDate'
Examples for Golang : 'string', 'int32', 'float32'

.updatable : String

Returns the 'updatable' flag value as string
( 'true' or 'false' or 'undefined' )

Since : 3.3.0

.updatableIs(boolean value) : boolean

Returns true if 'updatable' flag equals the given value
The flag can be 'undefined' then then neither true nor false

Parameters :
   value : the boolean value

Since : 3.3.0

.wrapperType : String

Returns the wrapper type corresponding to the attribute's primitive type
Examples : 'Float' for 'float', 'Integer' for 'int', 'Boolean' for 'boolean', ...
The attribute's type is retuned as is if it's not a primitive type