Search code examples
javaconstructorlombokaccess-levels

How to write the constructor instead of using Lombok to access public level?


I changed the access level protected to public but how to write the constructor instead of using Lombok for below code?

@RequiredArgsConstructor(access = AccessLevel.PUBLIC))
public class abc implements xyz<Event, Void> {

    @NonNull private final Test<Lock<TransactionLock, TransactionLockId>> test;

    ..... }

Solution

  • It should be if there are no other final fields defined:

    public class abc implements xyz<Event, Void> {
    
        @NonNull private final Test<Lock<TransactionLock, TransactionLockId>> test;
    
        public abc(@NotNull Test<Lock<TransactionLock, TransactionLockId>> test) {
            this.test = test;
        }
    j