projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.84k stars 2.38k forks source link

[FEATURE] Add support for records in @ToString or add new annotation to exclude params to not show in toString method #3452

Open Claudio-code opened 1 year ago

Claudio-code commented 1 year ago

Before submitting At the moment if you can log data of record that have PII data you need override toString and implement all method example:

public record UserRequest(String name, String email) {
    @Override
    public String toString() {
        return "UserRequest{" +
                "name='" + name + '\'' +
                '}';
    }
}

Describe the feature The idea would be to bring @ToString support from classes to records as well.

@ToString(exclude = {"email"})
public record UserRequest(String name, String email) {
}

Describe the target audience Everyone work in banks or companies that process sensitive data who wants use new features of java like records and continue having the facilities of lombok.

jimmyzzxhlh commented 3 months ago

Would be even better to support something like this:

public record SignInRequest(
    String email,
    @ToString.Exclude String password
) {
}