Removing deprecated NumberUtils.toInt methods [LANG-438]
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@753626 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5ca11e049c
commit
f62839527b
|
@ -86,28 +86,6 @@ public class NumberUtils {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* <p>Convert a <code>String</code> to an <code>int</code>, returning
|
||||
* <code>zero</code> if the conversion fails.</p>
|
||||
*
|
||||
* <p>If the string is <code>null</code>, <code>zero</code> is returned.</p>
|
||||
*
|
||||
* <pre>
|
||||
* NumberUtils.stringToInt(null) = 0
|
||||
* NumberUtils.stringToInt("") = 0
|
||||
* NumberUtils.stringToInt("1") = 1
|
||||
* </pre>
|
||||
*
|
||||
* @param str the string to convert, may be null
|
||||
* @return the int represented by the string, or <code>zero</code> if
|
||||
* conversion fails
|
||||
* @deprecated Use {@link #toInt(String)}
|
||||
* This method will be removed in Commons Lang 3.0
|
||||
*/
|
||||
public static int stringToInt(String str) {
|
||||
return toInt(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Convert a <code>String</code> to an <code>int</code>, returning
|
||||
* <code>zero</code> if the conversion fails.</p>
|
||||
|
@ -129,28 +107,6 @@ public class NumberUtils {
|
|||
return toInt(str, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Convert a <code>String</code> to an <code>int</code>, returning a
|
||||
* default value if the conversion fails.</p>
|
||||
*
|
||||
* <p>If the string is <code>null</code>, the default value is returned.</p>
|
||||
*
|
||||
* <pre>
|
||||
* NumberUtils.stringToInt(null, 1) = 1
|
||||
* NumberUtils.stringToInt("", 1) = 1
|
||||
* NumberUtils.stringToInt("1", 0) = 1
|
||||
* </pre>
|
||||
*
|
||||
* @param str the string to convert, may be null
|
||||
* @param defaultValue the default value
|
||||
* @return the int represented by the string, or the default if conversion fails
|
||||
* @deprecated Use {@link #toInt(String, int)}
|
||||
* This method will be removed in Commons Lang 3.0
|
||||
*/
|
||||
public static int stringToInt(String str, int defaultValue) {
|
||||
return toInt(str, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Convert a <code>String</code> to an <code>int</code>, returning a
|
||||
* default value if the conversion fails.</p>
|
||||
|
|
|
@ -68,16 +68,6 @@ public class NumberUtilsTest extends TestCase {
|
|||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Test for {@link NumberUtils#stringToInt(String)}.
|
||||
*/
|
||||
public void testDeprecatedStringToIntString() {
|
||||
assertTrue("stringToInt(String) 1 failed", NumberUtils.stringToInt("12345") == 12345);
|
||||
assertTrue("stringToInt(String) 2 failed", NumberUtils.stringToInt("abc") == 0);
|
||||
assertTrue("stringToInt(empty) failed", NumberUtils.stringToInt("") == 0);
|
||||
assertTrue("stringToInt(null) failed", NumberUtils.stringToInt(null) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {@link NumberUtils#toInt(String)}.
|
||||
*/
|
||||
|
@ -88,14 +78,6 @@ public class NumberUtilsTest extends TestCase {
|
|||
assertTrue("toInt(null) failed", NumberUtils.toInt(null) == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {@link NumberUtils#stringToInt(String, int)}.
|
||||
*/
|
||||
public void testDeprecatedStringToIntStringI() {
|
||||
assertTrue("stringToInt(String,int) 1 failed", NumberUtils.stringToInt("12345", 5) == 12345);
|
||||
assertTrue("stringToInt(String,int) 2 failed", NumberUtils.stringToInt("1234.5", 5) == 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for {@link NumberUtils#toInt(String, int)}.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue