Added javadoc to show that LANG-444 can be implemented by defaultIfEmpty, and proved it in the unit test

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@672995 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2008-07-01 04:53:50 +00:00
parent db5c7106a4
commit b353a8e999
2 changed files with 2 additions and 0 deletions

View File

@ -5308,6 +5308,7 @@ public static String defaultString(String str, String defaultStr) {
* StringUtils.defaultIfEmpty(null, "NULL") = "NULL" * StringUtils.defaultIfEmpty(null, "NULL") = "NULL"
* StringUtils.defaultIfEmpty("", "NULL") = "NULL" * StringUtils.defaultIfEmpty("", "NULL") = "NULL"
* StringUtils.defaultIfEmpty("bat", "NULL") = "bat" * StringUtils.defaultIfEmpty("bat", "NULL") = "bat"
* StringUtils.defaultIfEmpty("", null) = null
* </pre> * </pre>
* *
* @see StringUtils#defaultString(String, String) * @see StringUtils#defaultString(String, String)

View File

@ -1512,6 +1512,7 @@ public void testDefaultIfEmpty_StringString() {
assertEquals("NULL", StringUtils.defaultIfEmpty(null, "NULL")); assertEquals("NULL", StringUtils.defaultIfEmpty(null, "NULL"));
assertEquals("NULL", StringUtils.defaultIfEmpty("", "NULL")); assertEquals("NULL", StringUtils.defaultIfEmpty("", "NULL"));
assertEquals("abc", StringUtils.defaultIfEmpty("abc", "NULL")); assertEquals("abc", StringUtils.defaultIfEmpty("abc", "NULL"));
assertNull(StringUtils.defaultIfEmpty("", null));
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------