failsafe icon indicating copy to clipboard operation
failsafe copied to clipboard

Add toString() to all classes

Open numeralnathan opened this issue 2 years ago • 3 comments

Please implement toString() in all classes. This will help when debugging since the programmer can see what the state of the object is.

numeralnathan avatar Mar 03 '22 23:03 numeralnathan

Did you have classes in particular packages in mind, or all of them?

jhalterman avatar Mar 03 '22 23:03 jhalterman

All of them.

I was stepping through code that was calling RetryPolicyBuilder. It would be nice to see the state in the debugger to make sure I got the code right. I know I can expand the object and see it's fields, but this interrupts my flow.

Note: RetryPolicyImpl does not have any state except RetryPolicyConfig. So, this would be the implementation of RetryPolicyImpl.toString().

@Override
public String toString() {
   return config.toString();
}

However, RetryPolicyConfig has a lot of state. So, perhaps toString() only returns the values that are set. For example, if jitter is not set, then toString() won't show it.

numeralnathan avatar Mar 03 '22 23:03 numeralnathan

The easiest solution to make it done in five minutes :-)

https://projectlombok.org/features/ToString

magicprinc avatar Nov 26 '22 10:11 magicprinc