You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2003/11/01 20:34:08 UTC

Re: [lang] ToStringBuilder.reflectionToString() and statics.

From: "Gary Gregory" <gg...@seagullsw.com>
> A code review would be greatly appreciated, especially in how the feature
is
> surfaced at the API level.
>
> The main points are:
>
> (1)
> Deprecate in ReflectionToStringBuilder:
+1

> (2) New convenience methods ReflectionToStringBuilder.toStringWithStatics.
-1
I thought they would make things clearer, but I was wrong!

> Ideally I would have liked not to instantiate the target object, but it
> seems that Java's lack of a proper metadata model rears its ugly head here
> again. Unless I've missed something, which is quite possible of course.
>
> Doing this:
>
> ReflectionToStringBuilder.toStringWithStatics(MQEnvironment.class
> MQEnvironment.class);
>
> Will dump out the contents of the java.lang.Class object and so does not
do
> the same as the first example. It seems that you cannot get to the static
> side info from a java.lang.Class but only from an instance. Not very OO,
oh
> well.
You could have a   toStringStatics(Class, Class)  method. You can get the
field metadata about static methods from the Class object. The method could
only output static fields though, and I'm not sure how common the case is.

Stephen



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