Kushal Dixit created TEXT-238:
---------------------------------

             Summary: Overload CaseUtils.toCamelCase to default 
capitalizeFirstLetter=false
                 Key: TEXT-238
                 URL: https://issues.apache.org/jira/browse/TEXT-238
             Project: Commons Text
          Issue Type: Improvement
    Affects Versions: 1.14.0
            Reporter: Kushal Dixit


Right now, {{CaseUtils.toCamelCase(String, boolean, char...)}} always requires 
specifying the {{capitalizeFirstLetter}} flag.

In most real-world cases, users just want to convert a string to camelCase with 
the first letter lowercased by default, as that is basically what camelCase 
means originally.

*Proposal:* add a new overload:
{code:java}
public static String toCamelCase(String str, char... delimiters) { ... }
{code}
 * Since {{delimiters}} is already a varargs parameter, an overload without 
delimiters is not needed; callers can just omit it.
 * This overload will also be beneficial for *method references* in JDK 8+, 
making code like {{list.stream().map(CaseUtils::toCamelCase)}} cleaner.

*Examples:*
{code:java}
CaseUtils.toCamelCase("java-utils", '-');        // javaUtils
CaseUtils.toCamelCase("convert this string");    // convertThisString
CaseUtils.toCamelCase("hello_world", '_')        // helloWorld{code}
*Why it’s useful:*

Most callers just want the first letter lowercased. Requiring {{false}} every 
time is unnecessary boilerplate. This overload simplifies the API for the 
common case while keeping the existing method unchanged for backward 
compatibility.

*Note:* Looking for feedback and approval. If this makes sense, I will raise a 
PR with proper documentation and unit tests.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to