Groovy 2.2.1

[Java] Annotation Type BaseScript


public @interface BaseScript

Variable annotation used for changing the base script class of the current script.

The type of the variable annotated with {@BaseScript} must extend Script. It will be used as the base script class. The annotated variable will become shortcut to this object. Using this annotation will override base script set by Groovy compiler or CompilerConfiguration of GroovyShell Example usage:

 class CustomScript extends Script {
     int getTheMeaningOfLife() { 42 }
 @BaseScript CustomScript baseScript
 assert baseScript == this
 assert theMeaningOfLife == 42
 assert theMeaningOfLife == baseScript.theMeaningOfLife
In this example, the base script of the current script will be changed to CustomScript allowing usage of getTheMeaningOfLife() method. baseScript variable will become typed shortcut for this object which enables better IDE support.
Paul King
Vladimir Orany

Method Summary
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll

Copyright © 2003-2013 The Codehaus. All rights reserved.