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

Support map style annotation attribute declaration syntax

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.6-beta-1
    • None
    • syntax

    Description

      Given the following annotation type declaration in Java:

      public @interface Timeout { 
        int value(); 
        TimeUnit unit(); 
      } 
      

      In Java I can write:

      @Timeout(5, unit = TimeUnit.SECONDS) 
      

      The Groovy equivalent is slightly more verbose:

      @Timeout(value = 5, unit = TimeUnit.SECONDS) 
      

      Groovy should also allow the former style.

      Additionally, Jochen has suggested to allow the following styles (see http://www.nabble.com/Annotation-syntax%3A-Java-vs.-Groovy-to17217160.html):

      @Timeout(5, unit: TimeUnit.SECONDS)
      @Timeout(value: 5, unit: TimeUnit.SECONDS)
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            pniederw Peter Niederwieser
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: