Skip to content

Conversation

@kushal-dixit
Copy link

What this PR does

Implements [TEXT-238]: Add a convenience overload to CaseUtils.toCamelCase.

Currently, CaseUtils.toCamelCase(String, boolean, char...) always requires specifying the capitalizeFirstLetter flag.
In most real-world cases, callers just want camelCase with the first letter lowercased, which is the canonical meaning of camelCase.

This PR adds a new overload:

public static String toCamelCase(String str, char... delimiters) { ... }

By default, the first letter is lowercased (capitalizeFirstLetter = false).

Since delimiters is already a varargs parameter, no further overload is needed (e.g., toCamelCase(String) is already supported by omitting delimiters).

This also improves usability in JDK 8+ when using method references, e.g.:

list.stream().map(CaseUtils::toCamelCase)

Check List:

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request.
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best-practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

@garydgregory
Copy link
Member

I don't think we should do this and open the door further to support every variant for an API, we'd be just increasing the public API surface for very little gain IMO.

@garydgregory
Copy link
Member

Tracking ticket: https://issues.apache.org/jira/browse/TEXT-238

@kushal-dixit
Copy link
Author

Thanks Gary, I understand your point about keeping the API minimal. This PR adds only a trivial overload for the most common case (camelCase with a lowercase first letter). Since delimiters are varargs and capitalizeFirstLetter is boolean, I don’t think there are any further variant of this API.

I still think this overload makes sense, as in most cases camelCase is naturally understood to start with a lowercase letter, and this removes the need for callers to repeatedly pass false.

I’m happy to withdraw the PR if the consensus is to keep the API as-is.

@kushal-dixit
Copy link
Author

Since the associated Jira is marked as resolved won't fix, closing the PR.
Thanks @garydgregory and @ppkarwasz for the feedback, I will look for more meaningful changes for next time.

@kushal-dixit kushal-dixit deleted the feature/TEXT-238 branch September 12, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants