Randgalt / record-builder

Record builder generator for Java records
Apache License 2.0
758 stars 55 forks source link

Support records with 0 fields #9

Closed TedCassirer closed 4 years ago

TedCassirer commented 4 years ago

This is an edge case I came across while playing around. If you have a record with no fields the generated Builder source will have a duplicate 0 argument constructor.

Example:

@RecordBuilder
public record MyRecord() implements MyRecordBuilder.With{}

Generates:

@Generated("io.soabase.recordbuilder.core.RecordBuilder")
public class MyRecordBuilder {
    @Generated("io.soabase.recordbuilder.core.RecordBuilder")
    private MyRecordBuilder() {
    }

    @Generated("io.soabase.recordbuilder.core.RecordBuilder")
    private MyRecordBuilder() {
    }

   ...Rest of the class

This results in a compilation error

Randgalt commented 4 years ago

Thanks. I thought empty records were illegal. But I’ll check for it anyway

Randgalt commented 4 years ago

Fixed by https://github.com/Randgalt/record-builder/pull/10