Removing BooleanUtils.toBooleanObject(boolean) as JDK 1.4 provides Boolean.valueOf(boolean) - even if we ignore autoboxing. LANG-492

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@763559 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2009-04-09 08:34:47 +00:00
parent 07c1324202
commit 9adc537013
5 changed files with 13 additions and 35 deletions

View File

@ -3538,7 +3538,7 @@ public static Object[] add(Object[] array, int index, Object element) {
* (index < 0 || index > array.length).
*/
public static boolean[] add(boolean[] array, int index, boolean element) {
return (boolean[]) add(array, index, BooleanUtils.toBooleanObject(element), Boolean.TYPE);
return (boolean[]) add(array, index, Boolean.valueOf(element), Boolean.TYPE);
}
/**

View File

@ -35,7 +35,7 @@ public class BooleanUtils {
/**
* <p><code>BooleanUtils</code> instances should NOT be constructed in standard programming.
* Instead, the class should be used as <code>BooleanUtils.toBooleanObject(true);</code>.</p>
* Instead, the class should be used as <code>BooleanUtils.negate(true);</code>.</p>
*
* <p>This constructor is public to permit tools that require a JavaBean instance
* to operate.</p>
@ -148,23 +148,6 @@ public static boolean isNotFalse(Boolean bool) {
}
//-----------------------------------------------------------------------
/**
* <p>Boolean factory that avoids creating new Boolean objecs all the time.</p>
*
* <p>This method was added to JDK1.4 but is available here for earlier JDKs.</p>
*
* <pre>
* BooleanUtils.toBooleanObject(false) = Boolean.FALSE
* BooleanUtils.toBooleanObject(true) = Boolean.TRUE
* </pre>
*
* @param bool the boolean to convert
* @return Boolean.TRUE or Boolean.FALSE as appropriate
*/
public static Boolean toBooleanObject(boolean bool) {
return bool ? Boolean.TRUE : Boolean.FALSE;
}
/**
* <p>Converts a Boolean to a boolean handling <code>null</code>
* by returning <code>false</code>.</p>

View File

@ -549,7 +549,7 @@ public ToStringBuilder append(String fieldName, boolean[] array) {
* @return this
*/
public ToStringBuilder append(String fieldName, boolean[] array, boolean fullDetail) {
style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail));
return this;
}
@ -594,7 +594,7 @@ public ToStringBuilder append(String fieldName, byte[] array) {
* @return this
*/
public ToStringBuilder append(String fieldName, byte[] array, boolean fullDetail) {
style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail));
return this;
}
@ -640,7 +640,7 @@ public ToStringBuilder append(String fieldName, char[] array) {
* @return this
*/
public ToStringBuilder append(String fieldName, char[] array, boolean fullDetail) {
style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail));
return this;
}
@ -686,7 +686,7 @@ public ToStringBuilder append(String fieldName, double[] array) {
* @return this
*/
public ToStringBuilder append(String fieldName, double[] array, boolean fullDetail) {
style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail));
return this;
}
@ -732,7 +732,7 @@ public ToStringBuilder append(String fieldName, float[] array) {
* @return this
*/
public ToStringBuilder append(String fieldName, float[] array, boolean fullDetail) {
style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail));
return this;
}
@ -778,7 +778,7 @@ public ToStringBuilder append(String fieldName, int[] array) {
* @return this
*/
public ToStringBuilder append(String fieldName, int[] array, boolean fullDetail) {
style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail));
return this;
}
@ -824,7 +824,7 @@ public ToStringBuilder append(String fieldName, long[] array) {
* @return this
*/
public ToStringBuilder append(String fieldName, long[] array, boolean fullDetail) {
style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail));
return this;
}
@ -852,7 +852,7 @@ public ToStringBuilder append(String fieldName, Object obj) {
* @return this
*/
public ToStringBuilder append(String fieldName, Object obj, boolean fullDetail) {
style.append(buffer, fieldName, obj, BooleanUtils.toBooleanObject(fullDetail));
style.append(buffer, fieldName, obj, Boolean.valueOf(fullDetail));
return this;
}
@ -885,7 +885,7 @@ public ToStringBuilder append(String fieldName, Object[] array) {
* @return this
*/
public ToStringBuilder append(String fieldName, Object[] array, boolean fullDetail) {
style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail));
return this;
}
@ -931,7 +931,7 @@ public ToStringBuilder append(String fieldName, short[] array) {
* @return this
*/
public ToStringBuilder append(String fieldName, short[] array, boolean fullDetail) {
style.append(buffer, fieldName, array, BooleanUtils.toBooleanObject(fullDetail));
style.append(buffer, fieldName, array, Boolean.valueOf(fullDetail));
return this;
}

View File

@ -124,7 +124,7 @@ public boolean equals(Object obj) {
* @return the value as a Boolean
*/
public Object getValue() {
return BooleanUtils.toBooleanObject(this.value);
return Boolean.valueOf(this.value);
}
/**

View File

@ -101,11 +101,6 @@ public void test_isNotFalse_Boolean() {
}
//-----------------------------------------------------------------------
public void test_toBooleanObject_boolean() {
assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject(true));
assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject(false));
}
public void test_toBoolean_Boolean() {
assertEquals(true, BooleanUtils.toBoolean(Boolean.TRUE));
assertEquals(false, BooleanUtils.toBoolean(Boolean.FALSE));