Assigning Default Values to Entity Attributes

Attributes may be assigned default values using @DefaultValue annotation. Such an annotation must be added within the entity declaration just before the field definition.

The syntax is the following:

entity XXXXX {
   ...
   @DefaultValue("value1")
   attribute1 <elementaryType>
   ...
   @DefaultValue("value2")
   attribute2 <elementaryType>
   ...
}

The following example defines 10 as the default value for the quantity attribute of the ResourceCapacity entity:

entity ResourceCapacity {
    @DefaultValue("10")
    quantity Integer
}

The following table gives some examples by type.

Question Description Example
String String value, special character supported: \n (new line), \r (carriage return), \t (tabulation) @DefaultValue("Lorem ipsum dolor amet")
Instant a date in the ISO-8601 format @DefaultValue("2007-12-03T10:15:30.00Z")
LocalDate a local date in the ISO-8601 format @DefaultValue("2007-12-03")
LocalTime a local time in the ISO-8601 format @DefaultValue("10:15:30")
LocalDateTime a local date time in the ISO-8601 format @DefaultValue("2007-12-03T10:15:30")
Duration a duration in the ISO-8601 format or a double representing seconds @DefaultValue("PT20.345S") @DefaultValue("20.345")
Integer an integer value (e.g. 42) @DefaultValue("42")
ILong a long value @DefaultValue("42")
Double a double value @DefaultValue("42.5")
Boolean a boolean value 'true' or 'false' case-insensitive @DefaultValue("true")
Binary No default value support N/A