Closed GoogleCodeExporter closed 9 years ago
How many different types should we be adding special-case handling for, between
this and Optional?
(FYI, corresponding overloads would be necessary for all the primitive array
types in addition to Object[], so that's a total of nine overloads -- and then
should we be using deepToString just in case?)
Original comment by wasserman.louis
on 29 Aug 2012 at 3:14
imho, these methods in Objects aim to provide a fluent and simplified
implementation for toString/hashCode/equals . It is kind of losing its fluency
if we need to switch to other APIs, which is also error-prone (like me, I have
mistakenly use toStringHelper.add("anArray", anArray).
I used to use Apache Commons Lang's
ToStringBuilder/HashCodeBuilder/EqualsBuilder and it is handling arrays well.
I do hope to switch to Guava due to the ease of use and performance gain, but
array handling is a little nuisance which make Guava less enjoyable to use in
this aspect :)
Original comment by adrians...@gmail.com
on 30 Aug 2012 at 2:06
It would be too dangerous to try and change the equals() and hashCode()
behavior for arrays, but we like this idea for toStringHelper(). We'll just
make use of Arrays.deepToString().
Original comment by kak@google.com
on 23 Oct 2012 at 4:55
As Kurt says, this is mostly just a matter of changing Objects.ToStringBuilder
to append "Arrays.deepToString(value)" instead of just "value." Then you can
add some tests for the new behavior. It should make a decent introductory Real
CL.
http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#deepToString%28ja
va.lang.Object[]%29
Original comment by cpov...@google.com
on 20 May 2013 at 2:39
This issue has been migrated to GitHub.
It can be found at https://github.com/google/guava/issues/<id>
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:13
Original comment by cgdecker@google.com
on 1 Nov 2014 at 4:18
Original comment by cgdecker@google.com
on 3 Nov 2014 at 9:08
Original issue reported on code.google.com by
adrians...@gmail.com
on 29 Aug 2012 at 3:06