Hi Groovy people,

I have business logic that is written in terms of small closure.

I want to be able to combine as many closures as i want using logical operators &&, ||..

All these closures have a similar functional signature :
(DomainObject,User) -> boolean

Say, for example these three closures :

def isEnabled = {obj, user->user.enabled}
def canAccessObject= {obj, user->obj.owner?.id==user.id}
def isManager = {obj, user->user.hasRole('Manager')}

I want to be able to have a closure with the same signature :

def canProcessTransaction = isEnabled && canAccessObject || isManager

assert canProcessTransaction(basket,userService.loggedInUser)

Is there a Groovy way to do it?

Best regards