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

Support method references/method pointers in annotations

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 5.0.0-alpha-10
    • None
    • None

    Description

      The topic (for Java) appeared on social media recently:
      https://twitter.com/GeoffreyDeSmet/status/1808216150867861896

      Java thought it might be a good idea a while back but thought it would be hard to implement:
      https://mail.openjdk.org/pipermail/core-libs-dev/2018-November/056596.html

      For us we could use a Class typed annotation attribute and do like we currently do for closures, e.g.:

      @interface UIColorAnnotation {
          Class method()
      }
      @UIColorAnnotation(method = Person::getAgeColor)
          public int getAge() {
          }
          ...
      

      Since we already support closures, my thinking is to make the above exactly equivalent to:

      @UIColorAnnotation(method = { with(Person::getAgeColor) })
          public int getAge() {
          }
          ...
      

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              paulk Paul King
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: