DelegatesTo (groovy 2.4.3 API)
Date: 2015-03-23

Package: groovy.lang

## [Java] Annotation Type DelegatesTo

- groovy.lang.DelegatesTo

- This annotation can be used by API or DSL writers to document parameters which accept a closure. In that case, using this annotation, you can specify what the delegate type of the closure will be. This is important for IDE support.

  This annotation can also be used to help the type checker (TypeChecked) which would not report errors then if the delegate is of the documented type. Of course, it is also compatible with CompileStatic.

  Example:

       // Document the fact that the delegate of the closure will be an ExecSpec
       ExecResult exec(@DelegatesTo(ExecSpec) Closure closure) { ... }

  Authors:
    Cedric Champeau
    Peter Niderwieser
  Since:
    2.1.0

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static @interface` | `DelegatesTo.Target` |

  - ### Element Summary

    Optional Element Summary
    Type | Name and Description
    --- | ---
    `int` | `genericTypeIndex` @default 1
    `int` | `strategy` @default Closure.OWNER_FIRST
    `String` | `target` @default ""
    `String` | `type` The type member should be used when the type of the delagate cannot be represented with value(), genericTypeIndex() or target().
    `Class` | `value` @default Target.class

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Element Detail

    - #### public int genericTypeIndex

      @default 1

    - #### public int strategy

      @default Closure.OWNER_FIRST

    - #### public String target

      @default ""

    - #### public String type

      The type member should be used when the type of the delagate cannot be represented with value(), genericTypeIndex() or target(). In this case, it is possible to use a String to represent the type, at the cost of potential uncatched errors at compile time if the type is invalid and increased compile time. @default ""

      Returns:
        a String representation of a type
      Since:
        2.4.0

    - #### public Class value

      @default Target.class