tailorlala / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Should toStringHelper(Class|Object) use simple name or canonical name (or either)? #1864

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For some nested classes you would really rather toStringHelper chose the 
canonical name "Foo.Bar" instead of just the simple name "Bar".

Questions:

1. Which is the best default behavior?

2. If that is the canonical name, would it be evil to change it now? It is 
perhaps debatable whether the current behavior really is strongly promised by 
spec. Some overenthusiastic unit tests would have to be changed, but how bad is 
that?

3. Does this choice actually merit a new configuration option to 
ToStringHelper? Note that without it, users who want the opposite behavior will 
need to change typical (85%) usage code like so:

 toStringHelper(this) --> toStringHelper(getClass().getCanonicalName())

... which is not pleasant. However, we don't want ToStringHelper to become too 
complex.

Original issue reported on code.google.com by kevinb@google.com on 10 Oct 2014 at 7:22

GoogleCodeExporter commented 9 years ago
Possibly we should apply our decision here equally to AutoValue. (AutoValue 
currently appears to use "Bar.")

Original comment by cpov...@google.com on 14 Oct 2014 at 2:02

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<issue id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:08

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:17

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:07