annotation¶
Annotation allow metadata to be declared and used in data model constructs. These are extremely useful for tooling and applications to
Annotations are named and applicable target constructs (record
, entity
, enum
, trait
, service
, library
, union
, key
, udt
, field
, keyfield
) are defined as part of the declaration along with attributes.
annotation PII ( record, entity, field ) {
Sensitivity : SensitivityLevelType
}
enum SensitivityLevelType { Low, Medium, High }
Given the defintion above, it is possible to annotate records, entities or fields with PII
. As the field Sensitivity
is mandatory it needs to be specified, otherwise an error will be reported.
@PII( SensitivityLevelType.Low )
record Employee {
Name : string
@PII(SensitivityLevelType.High)
Salary : double
}
Built-in Annotations¶
@alfa.lang.Deprecated
: Used to denote the target definition has been deprecated and may be removed in future.@alfa.lang.IgnoreServiceWarnings
: To be used against aservice
to ignore references to unscopedtrait
types being flagged as an error ( as a transitive closure of a trait cannot be fully determined, which is potential issue between versions )@alfa.rt.SkipUnknownFields
: Ignore unknown fields when reading data for given type. Analogous to JSON SchemapermitAdditionalProperties
.@alfa.rt.http.Get
: Annotate against aservice
orlibrary
function to indicate when used as REST APIs, the method is considered a HTTP GET.@alfa.rt.http.Put
: HTTP PUT@alfa.rt.http.Post
: HTTP POST@alfa.rt.http.Delete
: HTTP DELETE@alfa.db.Table
: Type considered persistable. Numerous parameters to enable storage on Cloud Stores, Big Data, RDBMS or ObjectStores.