groovy读取类的函数签名的脚本

2015-12-14 0 780
groovy读取类的函数签名的脚本
if (args) {   
    def className = args[0]   
    def theClass = Class.forName(className)   
    def theMetaClass = theClass.metaClass   
    def printClass = { property ->   
        println "The $property of $className:"  
        if (theClass.class.metaClass.hasProperty(theClass, property))   
            theClass."$property".each { println it }   
        else if (theMetaClass.metaClass.hasProperty(theMetaClass, property))   
            theMetaClass."$property".each { println it }   
    }   
    if (args.size() == 1)   
        args = ['methods', 'metaMethods', 'constructors']   
    else  
        args = args[1..-1]   
    args.eachWithIndex { arg, index ->   
        if (index > 0)   
            println()   
        printClass(arg)   
    }   
} else {   
    println 'Print out the informations of the specified class.'  
    println 'Usage: PrintClass class-full-name [methods] [metaMethods] [constructors]'  
}  

遇见资源网 groovy groovy读取类的函数签名的脚本 http://www.ox520.com/13783.html

上一篇:

已经没有上一篇了!

下一篇:

已经没有下一篇了!

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务