-
Notifications
You must be signed in to change notification settings - Fork 10
Boolean converters
zhaber edited this page Aug 1, 2012
·
1 revision
By default functions and closures that return values of type Boolean are evaluated as validation expressions, but you can easily tell the rule engine to treat them as converters by applying the tilde operator:
inverseParameter toBoolean >> ~{!it}
or
// inverse return type is Boolean
inverseParameter toBoolean >> ~inverse
Another way of implementing boolean converters is a @Converter
annotation. It can be used for any method and exempts a developer from prefixing each validator call with the tilde-operator. For example:
@Converter
boolean inverse(boolean value) {
!value
}
inverseParameter toBoolean >> inverse