I need something as similar as possible to this:
interface Bar {
def doSomething()
}
class Foo { // does not implement Bar.
def doSomethingElse() {
}
Bar asBar() { // cast overload
return new Bar() {
def doSomething() {
doSomethingElse()
}
}
}
}
Foo foo = new Foo()
Bar bar = foo as Bar
bar.doSomething()
Is there something like this in Groovy?