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

Make @DelegatesTo support mapping to generic type argument

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.3
    • Fix Version/s: 2.2.0-beta-1
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: