[
https://issues.apache.org/jira/browse/TEXT-238?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18019625#comment-18019625
]
Kushal Dixit commented on TEXT-238:
-----------------------------------
Thanks [~pkarwasz] for the perspective, that makes sense.
I initially thought that since this JIRA was already marked as resolved, the
discussion was closed 🙂 but I see your point.
Instead of {{toLowerCamelCase}} / {{{}toUpperCamelCase{}}}, maybe it would be
more consistent to have {{toCamelCase}} (for lower camel case) and
{{toPascalCase}} (for the upper variant), since that’s how these cases are
commonly referred to.
These named methods would make the API cleaner and more self-explanatory. The
existing {{toCamelCase(String, boolean, char...)}} method could remain, but may
be marked as {{@Deprecated}} for backward compatibility.
I’m happy to adjust the PR (if it’s still open for discussion) according to
whichever approach is preferred either my suggestion ({{{}toCamelCase{}}} /
{{{}toPascalCase{}}}) or your suggestion ({{{}toLowerCamelCase{}}} /
{{{}toUpperCamelCase{}}}).
> 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
> Priority: Minor
>
> 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)