You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2022/11/19 14:54:00 UTC

[jira] [Updated] (GROOVY-10801) AST transform for simple utility classes (only static fields and methods)

     [ https://issues.apache.org/jira/browse/GROOVY-10801?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-10801:
---------------------------------
    Description: 
Similar to the {{@Category}} transform, I'd like to have a local transform for utility classes.  Consider the following:
{code:groovy}
@Namespace
class C {
  int constant = 1
  def method() {
    // ...
  }
}
{code}

This would be Groovy shorthand for the canonical "utility class":
{code:groovy}
final class C {
  private C() { throw new AssertionError() }
  public static final int constant = 1
  static method {
    // ...
  }
}
{code}

*Update:* Like trait or record, we might consider taking this to the next step:
{code:groovy}
namespace C {
  int constant = 1
  def method() {
    // ...
  }
}
{code}

  was:
Similar to the {{@Category}} transform, I'd like to have a local transform for utility classes.  Consider the following:
{code:groovy}
@Namespace
class C {
  int constant = 1
  def method() {
    // ...
  }
}
{code}

This would be Groovy shorthand for the canonical "utility class":
{code:groovy}
final class C {
  private C() { throw new AssertionError() }
  public static final int constant = 1
  static method {
    // ...
  }
}
{code}


> AST transform for simple utility classes (only static fields and methods)
> -------------------------------------------------------------------------
>
>                 Key: GROOVY-10801
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10801
>             Project: Groovy
>          Issue Type: New Feature
>          Components: ast builder
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>
> Similar to the {{@Category}} transform, I'd like to have a local transform for utility classes.  Consider the following:
> {code:groovy}
> @Namespace
> class C {
>   int constant = 1
>   def method() {
>     // ...
>   }
> }
> {code}
> This would be Groovy shorthand for the canonical "utility class":
> {code:groovy}
> final class C {
>   private C() { throw new AssertionError() }
>   public static final int constant = 1
>   static method {
>     // ...
>   }
> }
> {code}
> *Update:* Like trait or record, we might consider taking this to the next step:
> {code:groovy}
> namespace C {
>   int constant = 1
>   def method() {
>     // ...
>   }
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)