Created
April 21, 2016 04:43
-
-
Save takawitter/1c4f0bad41ce47f6a8394210dade6cc8 to your computer and use it in GitHub Desktop.
sample code to invoke ReflectionMethodInvoker of groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.codehaus.groovy.runtime.ReflectionMethodInvoker | |
class Base{} | |
class Derived extends Base{} | |
class Derived2 extends Derived{} | |
class Hello{ | |
public void hello(Base b){ | |
println "base" | |
} | |
public void hello(Derived d){ | |
println "derived"; | |
} | |
} | |
h = new Hello() | |
ReflectionMethodInvoker.invoke(h, "hello", new Base()) | |
ReflectionMethodInvoker.invoke(h, "hello", new Derived()) | |
ReflectionMethodInvoker.invoke(h, "hello", new Derived2()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base | |
derived | |
derived |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment