[
https://issues.apache.org/jira/browse/TEXT-85?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16046520#comment-16046520
]
ASF GitHub Bot commented on TEXT-85:
------------------------------------
Github user chtompki commented on a diff in the pull request:
https://github.com/apache/commons-text/pull/46#discussion_r121376797
--- Diff: src/main/java/org/apache/commons/text/CaseUtils.java ---
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.text;
+
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * <p>Case manipulation operations on Strings that contain words.</p>
+ *
+ * <p>This class tries to handle <code>null</code> input gracefully.
+ * An exception will not be thrown for a <code>null</code> input.
+ * Each method documents its behaviour in more detail.</p>
+ *
+ * @since 1.0
+ */
+public class CaseUtils {
+
+ /**
+ * <p><code>CaseUtils</code> instances should NOT be constructed in
+ * standard programming. Instead, the class should be used as
+ * <code>CaseUtils.toCamelCase("foo bar", true, new
char[]{'-'});</code>.</p>
+ * <p>
+ * <p>This constructor is public to permit tools that require a
JavaBean
+ * instance to operate.</p>
+ */
+ public CaseUtils() {
+ super();
+ }
+
+ // Camel Case
+
//-----------------------------------------------------------------------
+ /**
+ * <p>Converts all the delimiter separated words in a String into
camelCase,
+ * that is each word is made up of a titlecase character and then a
series of
+ * lowercase characters. The </p>
+ *
+ * <p>The delimiters represent a set of characters understood to
separate words.
+ * The first non-delimiter character after a delimiter will be
capitalized. The first String
+ * character may or may not be capitalized and it's determined by the
user input for capitalizeFirstLetter
+ * variable.</p>
+ *
+ * <p>A <code>null</code> input String returns <code>null</code>.
+ * Capitalization uses the Unicode title case, normally equivalent to
+ * upper case.</p>
+ *
+ * <pre>
+ * CaseUtils.toCamelCase(null, false)
= null
+ * CaseUtils.toCamelCase("", false, *)
= ""
+ * CaseUtils.toCamelCase(*, false, null)
= *
+ * CaseUtils.toCamelCase(*, true, new char[0])
= *
+ * CaseUtils.toCamelCase("To.Camel.Case", false, new char[]{'.'})
= "toCamelCase"
+ * CaseUtils.toCamelCase(" to @ Camel case", true, new char[]{'@'})
= "toCamelCase"
+ * CaseUtils.toCamelCase(" @to @ Camel case", false, new char[]{'@'})
= "toCamelCase"
+ * </pre>
+ *
+ * @param str the String to be converted to camelCase, may be null
+ * @param capitalizeFirstLetter boolean that determines if the first
character of first word should be title case.
+ * @param delimiters set of characters to determine capitalization,
null and/or empty array means whitespace
+ * @return camelCase of String, <code>null</code> if null String input
+ */
+ public static String toCamelCase(String str, boolean
capitalizeFirstLetter, final char... delimiters) {
--- End diff --
I think that we'll want:
```java
public static String toCamelCase(final String str, final boolean
capitalizeFirstLetter, final char... delimiters)
```
but I see that you've fiddled with the `str` variable below. So I'm open to
discussion on that point.
Generally, I'm torn on whether to have the signature be:
```java
public static String toCamelCase(final String str, final boolean
capitalizeFirstLetter, final char... delimiters);
```
or
```java
public static String toCamelCase(final CharSequence str, final boolean
capitalizeFirstLetter, final char... delimiters);
```
> Create CaseUtils class. Add toCamelCase
> ---------------------------------------
>
> Key: TEXT-85
> URL: https://issues.apache.org/jira/browse/TEXT-85
> Project: Commons Text
> Issue Type: Improvement
> Reporter: Rob Tompkins
> Assignee: Rob Tompkins
>
> Based on the conversation here:
> http://markmail.org/message/7nvizsbykvxpr7g5
> We wish to have a {{toCamelCase}} method. The suggestion is to create a
> {{CaseUtils}} class.
> I wonder if we should think about deprecating the case management in
> {{WordUtils}} and move it over? Maybe, maybe not.
> I would think our method signature would look something like:
> {code}
> String toCamelCase(String str, char delimiter, boolean capitalizeFirstLetter)
> {code}
> potentially with {{String}} replaced with {{CharSequence}}.
> Lastly, {{WordUtils.capitalizeFully(String str, final char... delimiters)}}
> might be a good starting point.
> https://github.com/apache/commons-text/blob/master/src/main/java/org/apache/commons/text/WordUtils.java#L467-L499
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)