1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 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]' } |