⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 groovyinterceptabletest.groovy

📁 大名鼎鼎的java动态脚本语言。已经通过了sun的认证
💻 GROOVY
字号:
import org.codehaus.groovy.runtime.ReflectionMethodInvokerclass GroovyInterceptableTest extends GroovyTestCase {    void testMethodInterception() {        def g = new GI()        assert g.someInt() == 2806        assert g.someUnexistingMethod() == 1        assert g.toString() == "invokeMethodToString"    }    void testProperties() {        def g = new GI()        assert g.foo == 89        g.foo = 90        assert g.foo == 90        // should this be 1 or 90?        assert g.getFoo() == 1    }}class GI implements GroovyInterceptable {    def foo = 89    int someInt() { 2806 }    String toString() { "originalToString" }    Object invokeMethod(String name, Object args) {        if ("toString" == name)            return "invokeMethodToString"        else if ("someInt" == name)            return ReflectionMethodInvoker.invoke(this, name, args)        else            return 1    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -