Break with Any closer in Groovy


class DeleteItDemoTest {


static main(args) {

DeleteItDemoTest test = new DeleteItDemoTest()
boolean res=test.isValidUser()
println "result is "+res

}


def isValidUser() {
def validRoleList = [
"ODUser",
"ODConfidentialUser"
]

def roles = ["ODREADUSER","ODConfidentialUser1","OBDUser"]
println"Role of AMITG==============>"+roles

def authorizedUser = false
roles.any{
if(it in validRoleList) {
authorizedUser = true
println "authorized user for action"+it
true
}else{
authorizedUser = false
println "unauthorized useuer for action"+it
}
}
return authorizedUser
}


}

Comments

Popular posts from this blog

Conversion from Clob To String in java and Vice versa

Portable Java 8/ JDK8 setup without admin rights

Multi Threading , Producer consumer problem in Java