I would like to update this sample code by using a lombok annotation. But I struggle to extract the registerCount
initialization from the constructor, because it depends on the injected collectorRegistry
bean.
@RestController
@RequestMapping("/api/user")
public class UserController {
private final UserService userService;
private final UserDetailsService userDetailsService;
private final Counter registerCount;
public UpdateUserController(UserService userService, UserDetailsService userDetailsService, CollectorRegistry collectorRegistry) {
this.userService = userService;
this.userDetailsService = userDetailsService;
registerCount = Counter.build()
.name("register_count")
.labelNames("domain_name", "domain_id")
.help("Number of registrations")
.register(collectorRegistry);
}
...
Is this possible in Lombok?
(I understand Lombok is not the holy grail, but I would like to know if this is also possible when using a lombok annotation like @RequiredArgsConstructor
)