Skip to content
This repository has been archived by the owner on Nov 3, 2024. It is now read-only.

Support static constructors using already-defined private constructors #687

Closed
kal4l opened this issue Oct 18, 2019 · 1 comment
Closed

Comments

@kal4l
Copy link

kal4l commented Oct 18, 2019

Short description

lombok version 1.18.10 added support for staticConstructor to utilize already existing constructors. See projectlombok/lombok#210

The plugin does not handle this.

Expected behavior

If I use staticConstructor when a private constructor already exists, the static constructor should be generated.

Version information

  • IDEA Version: 2019.2.2 Build #IC-192.6603.28
  • JDK Version: 1.8.0_181
  • OS Type & Version: macOS Mojave 10.14.6 (18G95)
  • Lombok Plugin Version: 0.27-2019.2
  • Lombok Dependency Version: 1.18.10

Example

The below class should have an of method generated. With the current plugin, StaticExample.of() will result in a Cannot resolve method 'of' error.

@Value(staticConstructor = "of")
public class StaticExample {

  String field;

  private StaticExample(String field) {
    System.out.println("this should be called");
    this.field = field;
  }

  public static void main(String[] args) {
    StaticExample example = StaticExample.of("test");
  }
}
@mplushnikov
Copy link
Owner

Already implemented by #681
Will be available in the next reselase!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants