Use custom setter in Lombok's builder with superclass

Sandro Rey :

I want to use custom setter in Lombok's builder and overwrite 1 method, like this

@SuperBuilder
public class User implements Employee {
    private static final PasswordEncoder ENCODER = new BCryptPasswordEncoder();

    private String username;

    private String password;

    public static class UserBuilder {
        public UserBuilder password(String password) {
            this.password = ENCODER.encode(password);
            return this;
        }
    }
}

but I have this compilation error

Existing Builder must be an abstract static inner class.
YCF_L :

Existing Builder must be an abstract static inner class.

The error mention the solution, A Quick fix should be using abstract like so:

public abstract static class UserBuilder

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=193290&siteId=1