A small project containing custom Groovy AST transformations. This allows classes to be decorated with methods at runtime through the use of Annotations.
1 @net.cghsystems.groocy.transform.Validatable(ValidatableReturnTypes)
This Groovy AST annotation will decorate all target objects with an isValid method. When called this will return a configurable type to determine if the target isValid. Currently an object is determined to be valid if all of its fields are set.
A return strategy can be configured by providing a ValidatableReturnTypes value to @Validatable(ValidatableReturnTypes):
-
BOOLEAN_FOR_INVALID: Returns false if the target object is deemed not valid
-
NOT_VALID_FOR_INVALID: Returns an net.cghsystems.groovy.transform.NotValid instance which provides a message detailing the fields not set on the target
Note
|
isValid will always return Boolean.TRUE if the target is deemed valid. |