Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-6956

Align the parameters of @DelegatesTo and @ClosureParams

    XMLWordPrintableJSON

Details

    • Wish
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.4
    • 2.4.0-beta-4
    • None
    • None

    Description

      Currently @DelegateTo allows to use the generic type of another argument of the call, but I actually need to delegate to one of the generic parameters of the enclosing class.

      I.e. my signature is:

      PipelineBuilder<T> map(
           boolean passThroughNulls = true, 
           @ClosureParams(value=FromString.class, options=["T"]) Closure<T> mapper
      ) 
      

      And I want the mapper closure to be able to refer to the payload through the delegate as well as the 'it' parameter.

      Unfortunately @DelegatesTo won't let me do this as it was written prior
      to @ClosureParams and it does not support things like FirstParam or FromString...

      Aligning the config params of @DeleatesTo and @ClosureParams, will make them more powerful and easier to learn.

      Attachments

        Activity

          People

            melix Cédric Champeau
            ddimitrov Dimitar Dimitrov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: