Groovy foreach
def generateUrl(SearchRequest searchRequest){
String url = TEST_URL
boolean first = true
searchRequest.requestParameters.each {key, value ->
if (first)
url += Constants.WHAT + key+Constants.EQUALS + value
else
url += Constants.AND + key + Constants.EQUALS + value
first = false
}
println "SEARCH REQUEST => ${url}"
url
}
Written by Prayag Upd
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Groovy
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#