Constraint specifies only one abstract method,
It has one special implementing inner class (not described in the API)
which is used to create a singleton instance
inside the kernel to serve as the typesafe value of
A constraint describes a set of entities. It also, in some sense, describes a type of entity. An application writer needs to know two things about entity sets:
- How do I describe what a certain set of entities should be?
- How do I determine if a particular entity is in a particular set of entities?
For the first function, application writers will use
your new constraint's constructor.
Your constructor may take an entity, or something related to entities
String for their name,
or even a set of entities.
It then constructs a way to describe entities of that type.
Alternately, your constraint may be a combinator.
These take an n-tuple of constraints of a particular type
take constraint tuples,
all take singleton constraints,
but you may add other combinators taking other sets of constraints)
and again produces a constraint describing entities of that type.
So, in either case, your new constraint's constructor must produce a description of a set of entities.
For the second function, the application writer wants to know
whether a particular constraint (which describes a particular set of entities)
can be satisfied by a particular entity.
To handle that case your new constraint must implement an
This takes an entity and returns a
specifying whether or not the given entity
is one of those described by your new constraint.
In sum, to create a constraint
you must implement interface
define a constructor for it,
and implement a
public boolean accepts(Entity) method.
There is no limit on the kinds of attributes, and therefore constraints, that developers can introduce into the system. For example, here is a possible constraint:
are you older than 5 days? are you bigger than 2 megs? do you contain the string "terry jones"? (case unimportant) do you contain the partial email address "jones@cliffs"? do you contain the string "here's the design"? do you reference images? do you contain a webpage? are you email? do you have more than 50 attributes? do you belong to more than 10 clusters? does the user visit you relatively often? have you been hit in searches more than 5 times?
Note that some attributes are intrinsic and unchanging (content strings, for example), some are dynamic and user-based (number of user visits, for example), and some are dynamic and system-derived (containing more than 50 attributes, for example). Developers can add any new kind of constraint they wish.