gcontracts Status Update

I am currently working on the gcontracts 1.0.1 release [0]. Apart from bug fixes, that version contains an important feature you might have been tumbled over: class invariant checking on Groovy bean properties. Groovy beans support a very simple syntax to declare properties [1]. E.g. adding a property firstName to your Person class is as simple as typing:
 
class Person {
    String firstName
    // ...
}
 
Compared to its Java equivalent that is as simple as it can get.
 
public class Person {
    private String firstName;

    public void setFirstName(String anotherFirstName)  {
        firstName = anotherFirstName;
    }

    public String getFirstName()  {
        return firstName;
    }
}
 
Up to now, gcontracts injected class invariants only in explicitly declared setter methods, but users reported the need for class invariant injection on writeable POGO properties. Today, i am glad to tell you that gcontracts class invariant injection mechanisms now works with POGO properties. Whenever a class declares an invariant, that invariant is injected in every dynamically generated setter method of that class. E.g. a class invariant like,
 
@Invariant({ firstName != null })
class Person {
    String firstName
    // ...
}
 
causes a java.lang.AssertionError whenever
 
def me = new Person("Andre")
me.firstName = null
 
is called. Support for class invariant injection in POGO properties is currently available in github's Master branch and will be part of gcontracts 1.0.1.

[0] Github - gcontracts
[1] Groovy Beans