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

Make @DelegatesTo support mapping to generic type argument

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.3
    • 2.2.0-beta-1
    • None
    • None

    Description

      Following the discussion at https://gist.github.com/alkemist/5429603, it would be interesting if Groovy allowed @DelegatesTo to map onto a generic type argument.

      For example:

      public <T> Object map(@DelegatesTo.Target List<T> target,  @DelegatesTo(genericTypeIndex=0) Closure arg) {
          arg.delegate = target.join('')
          arg()
      }
      def test() {
          def result
          map(['f','o','o']) {
              result = toUpperCase()
          }
      
          result
      }
      assert 'FOO'==test()
      

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: