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

Plugin is not compatible with Java records #64

Open
jrumbinas opened this issue Jun 30, 2023 · 0 comments
Open

Plugin is not compatible with Java records #64

jrumbinas opened this issue Jun 30, 2023 · 0 comments

Comments

@jrumbinas
Copy link

jrumbinas commented Jun 30, 2023

Here's a plugin output for record TestRecord(String a){}:

record TestRecord(String a){

    private TestRecord(Builder builder) {
        a = builder.a;
    }

    public static Builder builder(TestRecord copy) {
        Builder builder = new Builder();
        builder.a = copy.getA();
        return builder;
    }

    public static final class Builder {
        private String a;

        private Builder() {
        }

        public static Builder builder() {
            return new Builder();
        }

        public Builder withA(String val) {
            a = val;
            return this;
        }

        public TestRecord build() {
            return new TestRecord(this);
        }
    }
}

Two issues here:

  1. Record constructor needs to pass values via constructor (e.g. this(builder.a))
  2. Copy constructor is using copy.getA() instead of copy.a()
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

1 participant