Refactor code in ToStringBuilder.reflectionToString(...) into a new subclass called ReflectionToStringBuilder.

All of the ToStringBuilder.reflectionToString(...) forward their calls to equivalent methods in ReflectionToStringBuilde.
ReflectionToStringBuilder can  be subclassed to provide Field or value filtering.
Since the unit tests exercis ToStringBuilder.reflectionToString(...) which then forwards those calls to ReflectionToStringBuilder, and ReflectionToStringBuilder does not provide new features (yet), there are no new unit test cases (yet).


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137354 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2003-06-03 20:15:32 +00:00
parent a0be4d2757
commit 0cfce2932d
1 changed files with 7 additions and 3 deletions

View File

@ -68,7 +68,7 @@
* @author <a href="mailto:scolebourne@joda.org">Stephen Colebourne</a>
* @author <a href="mailto:ggregory@seagullsw.com">Gary Gregory</a>
* @author <a href="mailto:alex@apache.org">Alex Chaffee</a>
* @version $Id: ToStringBuilderTest.java,v 1.7 2003/03/27 08:55:22 ggregory Exp $
* @version $Id: ToStringBuilderTest.java,v 1.8 2003/06/03 20:15:32 ggregory Exp $
*/
public class ToStringBuilderTest extends TestCase {
@ -217,6 +217,10 @@ private String toBaseString(Object o) {
//
public void assertReflectionArray(String expected, Object actual) {
if (actual == null) {
// Until ToStringBuilder supports null objects.
return;
}
assertEquals(expected, ToStringBuilder.reflectionToString(actual));
assertEquals(expected, ToStringBuilder.reflectionToString(actual, null));
assertEquals(expected, ToStringBuilder.reflectionToString(actual, null, true));
@ -545,7 +549,7 @@ public String toString() {
public void testSimpleReflectionObjectCycle() throws Exception {
SimpleReflectionTestFixture simple = new SimpleReflectionTestFixture();
simple.o = simple;
assertTrue(ToStringBuilder.getReflectionRegistry().isEmpty());
assertTrue(ReflectionToStringBuilder.getRegistry().isEmpty());
assertEquals(this.toBaseString(simple) + "[o=" + this.toBaseString(simple) + "]", simple.toString());
this.validateEmptyReflectionRegistry();
}
@ -595,7 +599,7 @@ public void testReflectionArrayAndObjectCycle() throws Exception {
}
void validateEmptyReflectionRegistry() {
assertTrue(ToStringBuilder.getReflectionRegistry().isEmpty());
assertTrue(ReflectionToStringBuilder.getRegistry().isEmpty());
}
// End: Reflection cycle tests