I am trying to override the functionality of a method of a java type instance in my Groovy code but I am getting a classcast exception.
I looked at the guide posted her
Have you looked at Pimp my Library Pattern which allows you to add using Groovy Categories. You might find it more convenient and easy to understand in your case.
@Category(String)
class StringSubstrCategory {
def substring( int n) {
"This is not a very good substring implementation"
}
}
use (StringSubstrCategory) {
"hey".substring(1)
}