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

Allow conversion from closure to interface

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-RC-1
    • None
    • None
    • Patch

    Description

      It is relatively easy to adapt a closure to a one-method interface. And such conversion should be very useful for implementing functors from within groovy.

      syntax can be:

      {a->a.name=="a"}

      as Predicate

      The attached class is a dynamic proxy that implements this adapter functionality. It is currently used in a category class to enable a syntax like "Predicate.impl

      {...}

      ".

      Just hook it up to the "as" keyword should make it work.

      Attachments

        1. FromClosure.java
          2 kB
          benyu benyu

        Activity

          People

            blackdrag Jochen Theodorou
            ajoo benyu benyu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: