You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2022/05/29 06:42:55 UTC

[GitHub] [commons-lang] aherbert commented on a diff in pull request #903: Add toCharacterObject(String,String) with default value.

aherbert commented on code in PR #903:
URL: https://github.com/apache/commons-lang/pull/903#discussion_r884219852


##########
src/main/java/org/apache/commons/lang3/CharUtils.java:
##########
@@ -115,6 +115,33 @@ public static Character toCharacterObject(final String str) {
         return Character.valueOf(str.charAt(0));
     }
 
+    /**
+     * <p>Converts the String to a Character using the first character, returning a
+     *  default value if {@code null} or empty is passed in.</p>
+     *
+     * <p>For ASCII 7 bit characters, this uses a cache that will return the
+     * same Character object each time.</p>
+     *
+     * <pre>
+     *   CharUtils.toCharacterObject(null, 'A') = 'A'
+     *   CharUtils.toCharacterObject("", 'A')   = 'A'
+     *   CharUtils.toCharacterObject("A")  = 'A'

Review Comment:
   These docs require updating too



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org