Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Compact Constructors in Records #275

Open
pcimcioch opened this issue Dec 3, 2022 · 2 comments
Open

Support Compact Constructors in Records #275

pcimcioch opened this issue Dec 3, 2022 · 2 comments

Comments

@pcimcioch
Copy link

Library could support compact constructors in java records:

record Foo(String name, int x, int y) {
  Foo {
    Objects.requireNonNull(name);
  }
}

Currently, as a workaround you can ovveride the whole default constructor:

record Foo(String name, int x, int y) {
    Foo(String name, int x, int y) {
        this.name = Objects.requireNonNull(name);
        this.x = x;
        this.y = y;
    }
}
@gastaldi
Copy link
Member

gastaldi commented Dec 3, 2022

Good idea, want to provide a PR?

@pcimcioch
Copy link
Author

Would like, although I'm not sure when I'll have some time to ty it out, so not promising nothing :)

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

No branches or pull requests

2 participants