We'll use the following fact model:
Now, you can see that our core facts (Employee, PrivateJet) are supplemented by the @Traitable annotation. And we declared three additional facts for the proxy classes using the @format(trait) annotation. Notice that the traits share some of their fields with the traitable facts. When a trait is mapped to a traitable, the getters and setters of shared fields are remapped internally to the fields of the traitable automatically. Any core object fields that are not mapped in a trait, will be invisible to the trait.
Mapping an interface to a fact is quite easy, with the don keyword:
Now other rule may be able to fire:
Notice that the last example only propagates for an Employee that has both the Senior and Reviewable traits mapped. The isA operator provides easy cross-matching on Traits, although in this particular example it also would have been possible to match on the "wasReviewed" attribute of the Reviewable trait in exactly the same manner as the matching on 'code'.
Removing a trait is simple as well, using the shed operator: