Package groovy.transform
Annotation Type SelfType
This annotation can be added on a trait to declare the list of types that a class
 implementing that trait is supposed to extend. This is useful when you want to be
 able to call methods from the class implementing the trait without having to declare
 all of them as members of the trait.
 Self types are particularly useful in combination with 
CompileStatic,
 if you know that a trait can only be applied to a specific type but that the trait cannot extend
 that type itself. For example, imagine the following code:
 
     class Component { void methodInComponent() }
     trait ComponentDecorator {
         void logAndCall() {
             println "Calling method in component"
             methodInComponent()
         }
         // other useful methods
     }
     class DecoratedComponent extends Component implements ComponentDecorator {}
 CompileStatic, compilation
 will fail because the trait does not define the method. To declare that the trait can be
 applied on something that will extend Component, you need to add the SelfType
 annotation like this:
 
     class Component { void methodInComponent() }
     @CompileStatic
     @SelfType(Component)
     trait ComponentDecorator {
         void logAndCall() {
             println "Calling method in component"
             methodInComponent()
         }
         // other useful methods
     }
     class DecoratedComponent extends Component implements ComponentDecorator {}
 - Since:
- 2.4.0
- 
Required Element SummaryRequired Elements
- 
Element Details- 
valueClass[] value
 
-