diff --git a/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java b/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java index 06265b83e..af4cce041 100644 --- a/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java +++ b/src/java/org/apache/commons/lang/builder/HashCodeBuilder.java @@ -303,8 +303,8 @@ public class HashCodeBuilder { * the superclass to reflect up to (inclusive), may be null * @return int hash code */ - public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, Object object, - boolean testTransients, Class reflectUpToClass) { + public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, T object, + boolean testTransients, Class reflectUpToClass) { return reflectionHashCode(initialNonZeroOddNumber, multiplierNonZeroOddNumber, object, testTransients, reflectUpToClass, null); } @@ -354,8 +354,8 @@ public class HashCodeBuilder { * if the number is zero or even * @since 2.0 */ - public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, Object object, - boolean testTransients, Class reflectUpToClass, String[] excludeFields) { + public static int reflectionHashCode(int initialNonZeroOddNumber, int multiplierNonZeroOddNumber, T object, + boolean testTransients, Class reflectUpToClass, String[] excludeFields) { if (object == null) { throw new IllegalArgumentException("The object to build a hash code for must not be null"); diff --git a/src/java/org/apache/commons/lang/builder/ReflectionToStringBuilder.java b/src/java/org/apache/commons/lang/builder/ReflectionToStringBuilder.java index 57b74c8f7..d1b79bfb8 100644 --- a/src/java/org/apache/commons/lang/builder/ReflectionToStringBuilder.java +++ b/src/java/org/apache/commons/lang/builder/ReflectionToStringBuilder.java @@ -95,7 +95,7 @@ import org.apache.commons.lang.ClassUtils; * @since 2.0 * @version $Id$ */ -public class ReflectionToStringBuilder extends ToStringBuilder { +public class ReflectionToStringBuilder extends ToStringBuilder { /** *

@@ -284,9 +284,9 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * if the Object is null * @since 2.1 */ - public static String toString(Object object, ToStringStyle style, boolean outputTransients, boolean outputStatics, - Class reflectUpToClass) { - return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics) + public static String toString(T object, ToStringStyle style, boolean outputTransients, boolean outputStatics, + Class reflectUpToClass) { + return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics) .toString(); } @@ -361,8 +361,8 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * The field names to exclude * @return The toString value. */ - public static String toStringExclude(Object object, String[] excludeFieldNames) { - return new ReflectionToStringBuilder(object).setExcludeFieldNames(excludeFieldNames).toString(); + public static String toStringExclude(T object, String[] excludeFieldNames) { + return new ReflectionToStringBuilder(object).setExcludeFieldNames(excludeFieldNames).toString(); } /** @@ -383,7 +383,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { /** * The last super class to stop appending fields for. */ - private Class upToClass = null; + private Class upToClass = null; /** *

@@ -399,7 +399,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * @throws IllegalArgumentException * if the Object passed in is null */ - public ReflectionToStringBuilder(Object object) { + public ReflectionToStringBuilder(T object) { super(object); } @@ -419,7 +419,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * @throws IllegalArgumentException * if the Object passed in is null */ - public ReflectionToStringBuilder(Object object, ToStringStyle style) { + public ReflectionToStringBuilder(T object, ToStringStyle style) { super(object, style); } @@ -445,7 +445,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * @throws IllegalArgumentException * if the Object passed in is null */ - public ReflectionToStringBuilder(Object object, ToStringStyle style, StringBuffer buffer) { + public ReflectionToStringBuilder(T object, ToStringStyle style, StringBuffer buffer) { super(object, style, buffer); } @@ -466,7 +466,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * whether to include static fields * @since 2.1 */ - public ReflectionToStringBuilder(Object object, ToStringStyle style, StringBuffer buffer, Class reflectUpToClass, + public ReflectionToStringBuilder(T object, ToStringStyle style, StringBuffer buffer, Class reflectUpToClass, boolean outputTransients, boolean outputStatics) { super(object, style, buffer); this.setUpToClass(reflectUpToClass); @@ -616,7 +616,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * the array to add to the toString * @return this */ - public ToStringBuilder reflectionAppendArray(Object array) { + public ToStringBuilder reflectionAppendArray(Object array) { this.getStyle().reflectionAppendArrayDetail(this.getStringBuffer(), null, array); return this; } @@ -653,7 +653,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * The excludeFieldNames to excluding from toString or null. * @return this */ - public ReflectionToStringBuilder setExcludeFieldNames(String[] excludeFieldNamesParam) { + public ReflectionToStringBuilder setExcludeFieldNames(String[] excludeFieldNamesParam) { if (excludeFieldNamesParam == null) { this.excludeFieldNames = null; } else { @@ -671,7 +671,7 @@ public class ReflectionToStringBuilder extends ToStringBuilder { * @param clazz * The last super class to stop appending fields for. */ - public void setUpToClass(Class clazz) { + public void setUpToClass(Class clazz) { this.upToClass = clazz; } diff --git a/src/java/org/apache/commons/lang/builder/ToStringBuilder.java b/src/java/org/apache/commons/lang/builder/ToStringBuilder.java index b12c3ff5c..ccb53c9c2 100644 --- a/src/java/org/apache/commons/lang/builder/ToStringBuilder.java +++ b/src/java/org/apache/commons/lang/builder/ToStringBuilder.java @@ -90,7 +90,7 @@ import org.apache.commons.lang.ObjectUtils; * @since 1.0 * @version $Id$ */ -public class ToStringBuilder { +public class ToStringBuilder { /** * The default style of output to use. @@ -162,11 +162,11 @@ public class ToStringBuilder { * @see ReflectionToStringBuilder#toString(Object,ToStringStyle,boolean,boolean,Class) * @since 2.0 */ - public static String reflectionToString( - Object object, + public static String reflectionToString( + T object, ToStringStyle style, boolean outputTransients, - Class reflectUpToClass) { + Class reflectUpToClass) { return ReflectionToStringBuilder.toString(object, style, outputTransients, false, reflectUpToClass); } @@ -191,7 +191,7 @@ public class ToStringBuilder { /** * The object being output. */ - private final Object object; + private final T object; /** * The style of output to use. @@ -208,7 +208,7 @@ public class ToStringBuilder { * @throws IllegalArgumentException if the Object passed in is * null */ - public ToStringBuilder(Object object) { + public ToStringBuilder(T object) { this(object, getDefaultStyle(), null); } @@ -224,7 +224,7 @@ public class ToStringBuilder { * @throws IllegalArgumentException if the Object passed in is * null */ - public ToStringBuilder(Object object, ToStringStyle style) { + public ToStringBuilder(T object, ToStringStyle style) { this(object, style, null); } @@ -241,7 +241,7 @@ public class ToStringBuilder { * @param buffer the StringBuffer to populate, may be * null */ - public ToStringBuilder(Object object, ToStringStyle style, StringBuffer buffer) { + public ToStringBuilder(T object, ToStringStyle style, StringBuffer buffer) { if (style == null) { style = getDefaultStyle(); } @@ -264,7 +264,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(boolean value) { + public ToStringBuilder append(boolean value) { style.append(buffer, null, value); return this; } @@ -278,7 +278,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(boolean[] array) { + public ToStringBuilder append(boolean[] array) { style.append(buffer, null, array, null); return this; } @@ -292,7 +292,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(byte value) { + public ToStringBuilder append(byte value) { style.append(buffer, null, value); return this; } @@ -306,7 +306,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(byte[] array) { + public ToStringBuilder append(byte[] array) { style.append(buffer, null, array, null); return this; } @@ -320,7 +320,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(char value) { + public ToStringBuilder append(char value) { style.append(buffer, null, value); return this; } @@ -334,7 +334,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(char[] array) { + public ToStringBuilder append(char[] array) { style.append(buffer, null, array, null); return this; } @@ -348,7 +348,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(double value) { + public ToStringBuilder append(double value) { style.append(buffer, null, value); return this; } @@ -362,7 +362,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(double[] array) { + public ToStringBuilder append(double[] array) { style.append(buffer, null, array, null); return this; } @@ -376,7 +376,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(float value) { + public ToStringBuilder append(float value) { style.append(buffer, null, value); return this; } @@ -390,7 +390,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(float[] array) { + public ToStringBuilder append(float[] array) { style.append(buffer, null, array, null); return this; } @@ -404,7 +404,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(int value) { + public ToStringBuilder append(int value) { style.append(buffer, null, value); return this; } @@ -418,7 +418,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(int[] array) { + public ToStringBuilder append(int[] array) { style.append(buffer, null, array, null); return this; } @@ -432,7 +432,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(long value) { + public ToStringBuilder append(long value) { style.append(buffer, null, value); return this; } @@ -446,7 +446,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(long[] array) { + public ToStringBuilder append(long[] array) { style.append(buffer, null, array, null); return this; } @@ -460,7 +460,7 @@ public class ToStringBuilder { * @param obj the value to add to the toString * @return this */ - public ToStringBuilder append(Object obj) { + public ToStringBuilder append(Object obj) { style.append(buffer, null, obj, null); return this; } @@ -474,7 +474,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(Object[] array) { + public ToStringBuilder append(Object[] array) { style.append(buffer, null, array, null); return this; } @@ -488,7 +488,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(short value) { + public ToStringBuilder append(short value) { style.append(buffer, null, value); return this; } @@ -502,7 +502,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(short[] array) { + public ToStringBuilder append(short[] array) { style.append(buffer, null, array, null); return this; } @@ -515,7 +515,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, boolean value) { + public ToStringBuilder append(String fieldName, boolean value) { style.append(buffer, fieldName, value); return this; } @@ -528,7 +528,7 @@ public class ToStringBuilder { * @param array the array to add to the hashCode * @return this */ - public ToStringBuilder append(String fieldName, boolean[] array) { + public ToStringBuilder append(String fieldName, boolean[] array) { style.append(buffer, fieldName, array, null); return this; } @@ -548,7 +548,7 @@ public class ToStringBuilder { * for summary info * @return this */ - public ToStringBuilder append(String fieldName, boolean[] array, boolean fullDetail) { + public ToStringBuilder append(String fieldName, boolean[] array, boolean fullDetail) { style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail)); return this; } @@ -561,7 +561,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, byte value) { + public ToStringBuilder append(String fieldName, byte value) { style.append(buffer, fieldName, value); return this; } @@ -573,7 +573,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, byte[] array) { + public ToStringBuilder append(String fieldName, byte[] array) { style.append(buffer, fieldName, array, null); return this; } @@ -593,7 +593,7 @@ public class ToStringBuilder { * for summary info * @return this */ - public ToStringBuilder append(String fieldName, byte[] array, boolean fullDetail) { + public ToStringBuilder append(String fieldName, byte[] array, boolean fullDetail) { style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail)); return this; } @@ -606,7 +606,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, char value) { + public ToStringBuilder append(String fieldName, char value) { style.append(buffer, fieldName, value); return this; } @@ -619,7 +619,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, char[] array) { + public ToStringBuilder append(String fieldName, char[] array) { style.append(buffer, fieldName, array, null); return this; } @@ -639,7 +639,7 @@ public class ToStringBuilder { * for summary info * @return this */ - public ToStringBuilder append(String fieldName, char[] array, boolean fullDetail) { + public ToStringBuilder append(String fieldName, char[] array, boolean fullDetail) { style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail)); return this; } @@ -652,7 +652,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, double value) { + public ToStringBuilder append(String fieldName, double value) { style.append(buffer, fieldName, value); return this; } @@ -665,7 +665,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, double[] array) { + public ToStringBuilder append(String fieldName, double[] array) { style.append(buffer, fieldName, array, null); return this; } @@ -685,7 +685,7 @@ public class ToStringBuilder { * for summary info * @return this */ - public ToStringBuilder append(String fieldName, double[] array, boolean fullDetail) { + public ToStringBuilder append(String fieldName, double[] array, boolean fullDetail) { style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail)); return this; } @@ -698,7 +698,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, float value) { + public ToStringBuilder append(String fieldName, float value) { style.append(buffer, fieldName, value); return this; } @@ -711,7 +711,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, float[] array) { + public ToStringBuilder append(String fieldName, float[] array) { style.append(buffer, fieldName, array, null); return this; } @@ -731,7 +731,7 @@ public class ToStringBuilder { * for summary info * @return this */ - public ToStringBuilder append(String fieldName, float[] array, boolean fullDetail) { + public ToStringBuilder append(String fieldName, float[] array, boolean fullDetail) { style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail)); return this; } @@ -744,7 +744,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, int value) { + public ToStringBuilder append(String fieldName, int value) { style.append(buffer, fieldName, value); return this; } @@ -757,7 +757,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, int[] array) { + public ToStringBuilder append(String fieldName, int[] array) { style.append(buffer, fieldName, array, null); return this; } @@ -777,7 +777,7 @@ public class ToStringBuilder { * for summary info * @return this */ - public ToStringBuilder append(String fieldName, int[] array, boolean fullDetail) { + public ToStringBuilder append(String fieldName, int[] array, boolean fullDetail) { style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail)); return this; } @@ -790,7 +790,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, long value) { + public ToStringBuilder append(String fieldName, long value) { style.append(buffer, fieldName, value); return this; } @@ -803,7 +803,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, long[] array) { + public ToStringBuilder append(String fieldName, long[] array) { style.append(buffer, fieldName, array, null); return this; } @@ -823,7 +823,7 @@ public class ToStringBuilder { * for summary info * @return this */ - public ToStringBuilder append(String fieldName, long[] array, boolean fullDetail) { + public ToStringBuilder append(String fieldName, long[] array, boolean fullDetail) { style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail)); return this; } @@ -836,7 +836,7 @@ public class ToStringBuilder { * @param obj the value to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, Object obj) { + public ToStringBuilder append(String fieldName, Object obj) { style.append(buffer, fieldName, obj, null); return this; } @@ -851,7 +851,7 @@ public class ToStringBuilder { * false for summary info * @return this */ - public ToStringBuilder append(String fieldName, Object obj, boolean fullDetail) { + public ToStringBuilder append(String fieldName, Object obj, boolean fullDetail) { style.append(buffer, fieldName, obj, Boolean.valueOf(fullDetail)); return this; } @@ -864,7 +864,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, Object[] array) { + public ToStringBuilder append(String fieldName, Object[] array) { style.append(buffer, fieldName, array, null); return this; } @@ -884,7 +884,7 @@ public class ToStringBuilder { * for summary info * @return this */ - public ToStringBuilder append(String fieldName, Object[] array, boolean fullDetail) { + public ToStringBuilder append(String fieldName, Object[] array, boolean fullDetail) { style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail)); return this; } @@ -897,7 +897,7 @@ public class ToStringBuilder { * @param value the value to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, short value) { + public ToStringBuilder append(String fieldName, short value) { style.append(buffer, fieldName, value); return this; } @@ -910,7 +910,7 @@ public class ToStringBuilder { * @param array the array to add to the toString * @return this */ - public ToStringBuilder append(String fieldName, short[] array) { + public ToStringBuilder append(String fieldName, short[] array) { style.append(buffer, fieldName, array, null); return this; } @@ -930,7 +930,7 @@ public class ToStringBuilder { * for summary info * @return this */ - public ToStringBuilder append(String fieldName, short[] array, boolean fullDetail) { + public ToStringBuilder append(String fieldName, short[] array, boolean fullDetail) { style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail)); return this; } @@ -944,7 +944,7 @@ public class ToStringBuilder { * @return this * @since 2.0 */ - public ToStringBuilder appendAsObjectToString(Object object) { + public ToStringBuilder appendAsObjectToString(Object object) { ObjectUtils.identityToString(this.getStringBuffer(), object); return this; } @@ -963,7 +963,7 @@ public class ToStringBuilder { * @return this * @since 2.0 */ - public ToStringBuilder appendSuper(String superToString) { + public ToStringBuilder appendSuper(String superToString) { if (superToString != null) { style.appendSuper(buffer, superToString); } @@ -997,7 +997,7 @@ public class ToStringBuilder { * @return this * @since 2.0 */ - public ToStringBuilder appendToString(String toString) { + public ToStringBuilder appendToString(String toString) { if (toString != null) { style.appendToString(buffer, toString); } @@ -1010,7 +1010,7 @@ public class ToStringBuilder { * @return The object being output. * @since 2.0 */ - public Object getObject() { + public T getObject() { return object; } diff --git a/src/test/org/apache/commons/lang/builder/ToStringBuilderTest.java b/src/test/org/apache/commons/lang/builder/ToStringBuilderTest.java index 6ac15db31..078032c1e 100644 --- a/src/test/org/apache/commons/lang/builder/ToStringBuilderTest.java +++ b/src/test/org/apache/commons/lang/builder/ToStringBuilderTest.java @@ -340,7 +340,6 @@ public class ToStringBuilderTest extends TestCase { assertEquals(baseStr + "[a=a,transientA=t]", ToStringBuilder.reflectionToString(baseA, null, true)); assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA, null, false, null)); assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA, null, false, Object.class)); - assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA, null, false, List.class)); assertEquals(baseStr + "[a=a]", ToStringBuilder.reflectionToString(baseA, null, false, ReflectionTestFixtureA.class)); ReflectionTestFixtureB baseB = new ReflectionTestFixtureB(); @@ -352,7 +351,6 @@ public class ToStringBuilderTest extends TestCase { assertEquals(baseStr + "[b=b,transientB=t,a=a,transientA=t]", ToStringBuilder.reflectionToString(baseB, null, true)); assertEquals(baseStr + "[b=b,a=a]", ToStringBuilder.reflectionToString(baseB, null, false, null)); assertEquals(baseStr + "[b=b,a=a]", ToStringBuilder.reflectionToString(baseB, null, false, Object.class)); - assertEquals(baseStr + "[b=b,a=a]", ToStringBuilder.reflectionToString(baseB, null, false, List.class)); assertEquals(baseStr + "[b=b,a=a]", ToStringBuilder.reflectionToString(baseB, null, false, ReflectionTestFixtureA.class)); assertEquals(baseStr + "[b=b]", ToStringBuilder.reflectionToString(baseB, null, false, ReflectionTestFixtureB.class)); this.validateEmptyToStringStyleRegistry();