Open arjundt opened 1 month ago
I think that this is a very special corner case, exactly where you should write a custom old-fashioned toString()
instead of having it being generated by Lombok.
Of course, I might be wrong, but I don't think that this is common enough to be worth implementing.
Anyway, if this would be implemented, I think that this would be relatively easy to add something like @Truncate(maxLength = 16)
.
There was another issue made about modifying the output of specific fields in a toString method and the solution was to do something like this
@Data
public class Picture {
@ToString.Exclude
private String photo;
@ToString.Include(name = "photo")
public String getTruncatedPhoto() {
return truncate(photo);
}
}
This feature will help to truncate the long string variables(eg, photos, private/public keys, json strings etc) in toString() method. Although there is is an annotation to exclude a variable in toString() but incase someone wanted that variable in truncated format then this feature will be very helpful. Please find the example of truncated and non-truncated toString() method below.