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?
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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.