To declare a fact type you have to use the declare keyword followed by the fact name:

declare <type name>

In the next line you can declare the fact fields that the fact will contain. Each field declaration is created by the field name, followed by a colon (:) and finally the field type:

<field_name> : <field_type>

After the field declarations, you have to close the fact declaration with the end keyword.

Consider the following example:

package com.example.model

import java.util.List

declare Server
   name : String
   processors : int

   memory : int // megabytes
   diskSpace : int // gigabytes
   virtualizations : List // list of Virtualization objects
   cpuUsage : int // percentage
end

declare Virtualization
    name : String
    diskSpace : int
    memory : int
end
  • Types might optionally be declared in a package (namespace) using package keyword
  • To use a field type that is not included in the java.lang package, you will have to import it

Enumerative types

To declare enumerative type use enum keyword:

declare enum DaysOfWeek
	SUN, MON, TUE, WED, THU, FRI, SAT;
end

Declaring metadata

To declare a metadata attribute like author, whose value is Bob, you could simply write: @author( Bob ).

Declaring a fact type and assigning it the event role:

declare StockTick
    @role( event )

    datetime : java.util.Date
    symbol : String
    price : double
end

See Declaring New Types for full documentation.