users@jaxb.java.net

Re: JAXB2 commons-lang plugin suggestion

From: Hanson Char <hanson.char_at_gmail.com>
Date: Thu, 19 Apr 2007 12:37:58 -0700

I like the first option, allowing to specify the fully qualified
class name of a ToStringStyle subtype.

Hanson Char

On 4/19/07, Kenny MacLeod <kennym_at_kizoom.com> wrote:
> Hi Hanson,
>
> I was using your JAXB2 commons-lang plugin again today, and I have
> another suggested improvement, if you're interested.
>
> I had the need to use a custom ToStringStyle, which the plugin doesn't
> currently support. Two possibilities suggest themselves:
>
> * Extend the plugin args to allow the specification of the name of a
> ToStringStyle subtype, rather than the name of a static field of the
> ToStringStyle class itself.
>
> * Implement a second toString() method on the generated code, which
> takes as an argument a ToStringStyle instance. So this qwould give you
> code like this:
>
> @Override
> public String toString() {
> return toString(ToStringStyle.MULTI_LINE_STYLE);
> }
>
> public String toString(ToStringStyle toStringStyle) {
> return ToStringBuilder.reflectionToString(this, toStringStyle);
> }
>
> The second one is nice and flexible, and requires no classpath
> alterations, unlike the first approach.
>
>
> What do you think?
> cheers
> kenny
>