All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nz.ac.auckland.lmz.controlpanel.shell.LMZGroovyShellScriptBase.groovy Maven / Gradle / Ivy

There is a newer version: 3.3
Show newest version
package nz.ac.auckland.lmz.controlpanel.shell


abstract class LMZGroovyShellScriptBase extends Script{

	/**
	 * Example function, will be available from withing script
	 * @return
	 */
	void listBeans() {
		getBinding().getVariable('ctx').getBeanDefinitionNames().sort().each{
			this.println(it)
		}
	}

	void listBeanMethods(Object bean){
		def allMethods = bean.metaClass.getMetaMethods()*.name + bean.metaClass.getMethods()*.name
		def allGenericMethods =  new Object().metaClass.getMethods()*.name + new Object().metaClass.getMetaMethods()*.name

		def result = allMethods - allGenericMethods // remove all methods that groovy adds to all objects

		// filter crap
		result.unique()
		result = result.findAll {
			return !it.contains('$')
		}
		result = result.sort();


		println "[${result.join('\n')}]"
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy