how can i dynamically cast oject to a specific class which is given as a string. e.g.
def a = (ClassA) testService.getObject(xmlString)
i would like to do something like this
开发者_如何转开发(grailsApplication.getClassForName(classString)) testService.getObject(xmlString)
but the groovy compiler does not like this way of cast operation.
you could do
Class myClass = grailsApplication.getClassForName(classString)
myClass.cast testService.getObject(xmlString)
but I'm not sure how groovy
this way is - it's really just Java way..
精彩评论