@ToString need feature to mask output

940 views
Skip to first unread message

vinothm

unread,
Jul 29, 2018, 2:36:15 AM7/29/18
to Project Lombok
Hi Team,

I have constant requirement in our projects print masked data part logs, this help debug quickly and does allow user to mask output to certain characters.

Example:

public class ReportRequest {

    @ToString.masked(3) public String userId;

}

If called with value as vinothm, should print vin****.

Can this be added as feature to the ToString annotation?

Thanks,
VinothM

Martin Grajcar

unread,
Jul 29, 2018, 3:11:02 PM7/29/18
to project...@googlegroups.com
I'm afraid, that's much too specialized for any general purpose tool.

But you can write

@ToString.Include
private userId() {
    return userId.length() <= 3 ? userId
    : userId.substring(0, 3) + com.google.common.base.Strings.repeat("*", userId.length() - 3);
}

and Lombok picks it instead of the field.


--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombo...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

vinoth marimuthu

unread,
Jul 29, 2018, 6:39:33 PM7/29/18
to project...@googlegroups.com
Thank you, I agree this adding more specific requirement.  I can follow the suggestion.
Reply all
Reply to author
Forward
0 new messages