#152 Facet Design

brian Thu 23 Aug 2007

Proposed names: Facets, Annotations, Attributes, Tags, Aspects - 1st choice is annotations, but too long to type, so we'll stick with facets

Facets are normal const classes which are serializable (similar to C# attribute definition). Types and slots (and maybe parameters?) are tagged with facets Java style using the @ symbol followed by normal Fan serialization syntax.

const class PrimaryKey : Facet {} // marker facet

const class Column : Facet // complex facet
{
  const Str name
  const Int width := 15
}

class Customer
{
  @PrimaryKey
  @Column { name="cust_name"; width=20 }
  Str name

  @Column { name="cust_description"; width=60 }
  Str description
}

We won't do facets for facets target (type, field, method, etc like Java/C#) - seems overkill.

New APIs for facet access on Type and Slot (and maybe Param):

Facet[] facets(Type t := null)
Facet facet(Type t)

brian Wed 21 Nov 2007

Actually the design didn't turn out like this, rather facets turned into name/value pairs where the name is an string identifier and value is any serialized object.

Login or Signup to reply.