Skip to content

Plugin is not compatible with Java records #64

@jrumbinas

Description

@jrumbinas

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions