Skip to main content

Custom Model Annotation

Why Custom Annotation?

This is a way to extend metamodel : to add more properties to entities (class, vars, methods … and any entities)

Entities properties (or Tags) are then used at runtime.

Custom Annotation use cases:

  • To tag Deprecated methods, vars, ….
  • Test methods
  • Serialization property: ignore, rename

How to Implement and Use Custom Annotation

How to create annotation Class

You just have to create a class under aAnnotation, for example:

TestAnnotation
; TestAnnotation (aAnnotation) (Def Version:2) (Implem Version:2)

class TestAnnotation (aAnnotation)

Title : CString

How to Annotate Entity

Simply attach it with [Test(Title='')]

example:

; aTestAnnot (aNamedObject) (Def Version:5) (Implem Version:8)

class aTestAnnot (aNamedObject)

uses TestAnnotation

[Test(Title:'Values must be valid')]
function SumValues return Boolean
endFunc

How to get annotation of entity

Call aEntity.getAnnotation(theClass : aClassDef) return aLightObject

=> Is returning an instance of Annotation class

var method: aMethodDef
var testAnnot: TestAnnotation

method = MetaModelentity(aTestAnnot.SumValues)
testAnnot = method.getAnnotation(Metamodelentity(TestAnnotation))

Next, you can search for all Test methods and use aMethodInvokable to call them.