I always seem to be needing to cast values in the params object in order to perform a .equals but it never feels right. If i use the parseXXX methods I also have to protect myself when the value is empty. It seems like there would be a better way to handle this in a dynamic language like Groovy. Has anyone found a different way that feels more like Groovy and less like Java? I could build a utility class to clean this up but I am looking for some built in functionality so please don’t suggest additional libraries.
Example:
def intValue = (params.intValue)? Integer.parseInt(params.intValue) :null
Things.each{ thing ->
if (thing.intValue.equals(intValue)){
//do stuff
}
}
What about using the Type Conversion Methods: