Groovy web console

subscribe to the feed Subscribe
to this
site

test isNullOrEmpty

Published 1 month ago by Anonymous
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
String ok1= "ok"
List<String> ok2=["ok"]
Map ok3=[test: "ok"]
Integer ok4=15

String ko1=""
Object ko2=null
List<String> ko3=new ArrayList()
Map ko4=[:]

boolean isNullOrEmpty(Object object) {
   return object ? true : false
   //return object
}

[
isNullOrEmpty(ok1),
isNullOrEmpty(ok2),
isNullOrEmpty(ok3),
isNullOrEmpty(ok4),
isNullOrEmpty(ko1),
isNullOrEmpty(ko2),
isNullOrEmpty(ko3),
isNullOrEmpty(ko4)
]