commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@gmail.com>
Subject Re: [Lang] Pair toString
Date Mon, 11 Apr 2011 14:12:29 GMT
On Mon, Apr 11, 2011 at 9:00 AM, Gary Gregory <garydgregory@gmail.com> wrote:
> Hi All:
>
> I added a test to verify the default Pair toString behavior.
>
> For me to replace our custom Pair class at work, I need to customize the to
> String behavior.
>
> Subclassing ImmutablePair and MutablePair to override toString smells nasty.
>
> What about adding a formatString ivar which will be used with the
> String.format API?
>

If we must do anything like this it would seem that by the laws of dog
food we would accept Builder<String>.  That said, I'm finding it
difficult to see a way to do this that doesn't seem equally offensive
as the subclassing approach you've rejected.  For a different
subclassing approach you could implement toString() at a single
point--a direct Pair subclass--and then reimplement mutable and
immutable versions if you really needed both.  Or if your toString()
needs are nonspecific enough, maybe we can just use them--I'm not
unduly attached to the current format.

Matt

> --
> Thank you,
> Gary
>
> http://garygregory.wordpress.com/
> http://garygregory.com/
> http://people.apache.org/~ggregory/
> http://twitter.com/GaryGregory
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message