1

Lombok version is 1.18.0.

I have @Builder set on class level.

When I try to set a default value for a list variable:

@Builder.Default
@Singular
private List<Class<? extends Exception>> retryTriggers = Lists.newArrayList(Exception.class);

I got an error:

Error:(46, 5) java: @Builder.Default and @Singular cannot be mixed.

Besides writing the builder myself, is there another way to do this?

Tomasz Linkowski
  • 4,386
  • 23
  • 38
Furyegg
  • 410
  • 1
  • 5
  • 18

1 Answers1

4

I would suggest replacing the generated builder() method with the following one:

@Builder
class ExceptionHandler {
    @Singular
    private final List<Class<? extends Exception>> retryTriggers;

    public static ExceptionHandlerBuilder builder() {
        return new ExceptionHandlerBuilder().retryTrigger(Exception.class);
    }
}
Tomasz Linkowski
  • 4,386
  • 23
  • 38