Hey,

I have just committed a first implementation of Constraints on 
Properties. Basically, you can do this.
interface MyDomain
{
   @NotNull Property<String> someName();
}

which when you call instance.someName().set(null) will throw a 
ConstraintViolationException (subclass of IllegalArgumentException), 
which contains information about what went wrong which can then be 
converted to localized messages for human viewing. Pretty straightforward.

Two things I want to do next are:
* Allow the @Constraints declaration to be on the actual annotation 
interface rather than in the Composite type declaration. This will make 
it sooo much easier to use
* Allow compound Constraints, such as:

@ConstraintDeclaration
@NotNull @Matches("\d{n,}")
@interface ZipCode {}

so that I can simply do:
interface Address
{
  ...
  @ZipCode Property<String> zipCode();
}
instead of having to define it through the individual rules. This should 
make it possible to do reasonably complex checks without cluttering the 
interface declarations too much I hope.

Whaddyathink?

/Rickard

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to