Randgalt / record-builder

Record builder generator for Java records

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Does not handle overriden accessors

krzyk opened this issue · comments

Following class will fail if used with @RecordBuilder:

@RecordBuilder
public record ExceptionDetails(
    String internalMessage, String endUserMessage, HttpStatus httpStatus,
    ErrorType errorType, List<JsonProblem> jsonProblems, Throwable cause
) {
    @Override
    public List<JsonProblem> jsonProblems() {
        if (jsonProblems == null) {
            return List.of();
        }
        return jsonProblems;
    }
}

It fails with:

ExceptionDetailsBuilder.java:[195,4] error: method does not override or implement a method from a supertype

I looked at the options but I couldn't find anything that would help with that.

This is from version 24

The issue here is that @Override is copied along with the method into the builder and it doesn't override anything there. So there should be exclude not to copy that annotation.

If I don't provide it in the record everything works fine.