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

AST transform for simple utility classes (only static fields and methods)

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • ast builder
    • None

    Description

      Similar to the @Category transform, I'd like to have a local transform for utility classes. Consider the following:

      @Namespace
      class C {
        int constant = 1
        def method() {
          // ...
        }
      }
      

      This would be Groovy shorthand for the canonical "utility class":

      final class C {
        private C() { throw new AssertionError() }
        public static final int constant = 1
        static method {
          // ...
        }
      }
      

      Update: Like trait or record, we might consider taking this to the next step:

      namespace C {
        int constant = 1
        def method() {
          // ...
        }
      }
      

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: