Groovy 2.2.1

groovy.transform
[Java] Annotation Type BaseScript

java.lang.Object
  groovy.transform.BaseScript

@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.LOCAL_VARIABLE})
@GroovyASTTransformationClass("org.codehaus.groovy.transform.BaseScriptASTTransformation")
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.
Authors:
Paul King
Vladimir Orany
Since:
2.2.0


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

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