LANG-940: Fix deprecation warnings

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1557584 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benedikt Ritter 2014-01-12 18:26:49 +00:00
parent 2b795dd03a
commit d048a37502
10 changed files with 33 additions and 12 deletions

View File

@ -22,6 +22,7 @@
<body>
<release version="3.3" date="TBA" description="Bugfix and Feature release">
<action issue="LANG-940" type="update" dev="britter">Fix deprecation warnings</action>
<action issue="LANG-819" type="update" dev="mbenson">EnumUtils.generateBitVector needs a "? extends"</action>
<action issue="LANG-834" type="add" dev="britter">Validate: add inclusiveBetween and exclusiveBetween overloads for primitive types</action>
<action issue="LANG-900" type="add" dev="britter" due-to="Duncan Jones">New RandomUtils class</action>

View File

@ -207,6 +207,11 @@ public class ObjectUtils {
return obj == null ? 0 : obj.hashCode();
}
@Override
public String toString() {
return super.toString();
}
/**
* <p>Gets the hash code for multiple objects.</p>
*

View File

@ -4039,7 +4039,9 @@ public class StringUtils {
}
final Object first = iterator.next();
if (!iterator.hasNext()) {
return ObjectUtils.toString(first);
@SuppressWarnings( "deprecation" ) // ObjectUtils.toString(Object) has been deprecated in 3.2
String result = ObjectUtils.toString(first);
return result;
}
// two or more elements
@ -4083,7 +4085,9 @@ public class StringUtils {
}
final Object first = iterator.next();
if (!iterator.hasNext()) {
return ObjectUtils.toString(first);
@SuppressWarnings( "deprecation" ) // ObjectUtils.toString(Object) has been deprecated in 3.2
final String result = ObjectUtils.toString(first);
return result;
}
// two or more elements

View File

@ -101,6 +101,7 @@ public class ConstantInitializer<T> implements ConcurrentInitializer<T> {
* @param obj the object to compare to
* @return a flag whether the objects are equal
*/
@SuppressWarnings( "deprecation" ) // ObjectUtils.equals(Object, Object) has been deprecated in 3.2
@Override
public boolean equals(final Object obj) {
if (this == obj) {

View File

@ -203,6 +203,7 @@ public class TypeUtils {
/**
* {@inheritDoc}
*/
@SuppressWarnings( "deprecation" ) // ObjectUtils.hashCode(Object) has been deprecated in 3.2
@Override
public int hashCode() {
int result = 71 << 4;
@ -1566,6 +1567,7 @@ public class TypeUtils {
* @return boolean
* @since 3.2
*/
@SuppressWarnings( "deprecation" ) // ObjectUtils.equals(Object, Object) has been deprecated in 3.2
public static boolean equals(Type t1, Type t2) {
if (ObjectUtils.equals(t1, t2)) {
return true;

View File

@ -289,6 +289,7 @@ public class ExtendedMessageFormat extends MessageFormat {
*
* @return the hashcode
*/
@SuppressWarnings( "deprecation" ) // ObjectUtils.hashCode(Object) has been deprecated in 3.2
@Override
public int hashCode() {
int result = super.hashCode();

View File

@ -1128,12 +1128,13 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @param separator the separator to use, null means no separator
* @return this, to enable chaining
*/
public StrBuilder appendWithSeparators(final Object[] array, String separator) {
public StrBuilder appendWithSeparators(final Object[] array, final String separator) {
if (array != null && array.length > 0) {
separator = ObjectUtils.toString(separator);
@SuppressWarnings( "deprecation" ) // ObjectUtils.toString(Object) has been deprecated in 3.2
final String sep = ObjectUtils.toString(separator);
append(array[0]);
for (int i = 1; i < array.length; i++) {
append(separator);
append(sep);
append(array[i]);
}
}
@ -1150,14 +1151,15 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @param separator the separator to use, null means no separator
* @return this, to enable chaining
*/
public StrBuilder appendWithSeparators(final Iterable<?> iterable, String separator) {
public StrBuilder appendWithSeparators(final Iterable<?> iterable, final String separator) {
if (iterable != null) {
separator = ObjectUtils.toString(separator);
@SuppressWarnings( "deprecation" ) // ObjectUtils.toString(Object) has been deprecated in 3.2
final String sep = ObjectUtils.toString(separator);
final Iterator<?> it = iterable.iterator();
while (it.hasNext()) {
append(it.next());
if (it.hasNext()) {
append(separator);
append(sep);
}
}
}
@ -1174,13 +1176,14 @@ public class StrBuilder implements CharSequence, Appendable, Serializable, Build
* @param separator the separator to use, null means no separator
* @return this, to enable chaining
*/
public StrBuilder appendWithSeparators(final Iterator<?> it, String separator) {
public StrBuilder appendWithSeparators(final Iterator<?> it, final String separator) {
if (it != null) {
separator = ObjectUtils.toString(separator);
@SuppressWarnings( "deprecation" ) // ObjectUtils.toString(Object) has been deprecated in 3.2
final String sep = ObjectUtils.toString(separator);
while (it.hasNext()) {
append(it.next());
if (it.hasNext()) {
append(separator);
append(sep);
}
}
}

View File

@ -125,6 +125,7 @@ public abstract class Pair<L, R> implements Map.Entry<L, R>, Comparable<Pair<L,
* @param obj the object to compare to, null returns false
* @return true if the elements of the pair are equal
*/
@SuppressWarnings( "deprecation" ) // ObjectUtils.equals(Object, Object) has been deprecated in 3.2
@Override
public boolean equals(final Object obj) {
if (obj == this) {

View File

@ -105,6 +105,7 @@ public abstract class Triple<L, M, R> implements Comparable<Triple<L, M, R>>, Se
* @param obj the object to compare to, null returns false
* @return true if the elements of the triple are equal
*/
@SuppressWarnings( "deprecation" ) // ObjectUtils.equals(Object, Object) has been deprecated in 3.2
@Override
public boolean equals(final Object obj) {
if (obj == this) {

View File

@ -280,12 +280,14 @@ public class ObjectUtilsTest {
}
}
@SuppressWarnings( "deprecation" ) // ObjectUtils.toString(Object) has been deprecated in 3.2
@Test
public void testToString_Object() {
assertEquals("", ObjectUtils.toString((Object) null) );
assertEquals(Boolean.TRUE.toString(), ObjectUtils.toString(Boolean.TRUE) );
}
@SuppressWarnings( "deprecation" ) // ObjectUtils.toString(Object) has been deprecated in 3.2
@Test
public void testToString_ObjectString() {
assertEquals(BAR, ObjectUtils.toString((Object) null, BAR) );