speters33w commented on PR #528:
URL: https://github.com/apache/commons-text/pull/528#issuecomment-2057162412

   I've rewritten the code in CaseUtils based on comments and some more 
aggressive tests I devised. I've removed many unnecessary methods such as 
toScreamingCase, etc. that can be easily reproduced by a user. I changed the 
main engine to toDelimitedCase, which accepts a boolean to uncapitalize the 
very first letter of the string, and a "separator" (to differentiate it from 
delimiters in the existing CamelCase()). I retained my toCamelCase(str), 
toPascalCase, toSnakeCase, and toKebabCase even though these could be 
reproduced by a user using toDelimitedCase to make it easier for a user.
   I did add some todos thatI haven't completed yet, precompiling regex 
patterns, reducing cyclomatic complexity in toDelimitedCase, and testing to see 
if I should replace my instance of StringBuilder to 
commons.text.TextStringBuilder.
   
   I also wrote some very aggressive tests with null values for all parameters, 
line breaks, tabs, etc.
   
   
https://github.com/speters33w/commons-text/commit/5972912f9613fbdd1360c5bc3f5fe175e05ab973
   
   This is what you get in the revised version:
   
   ```
    *                                                           "Two words" 
"foo bar" "Piñata Café"
    * camelCase        toCamelCase(str)                         "twoWords"  
"fooBar"  "pinataCafe"
    * camelCase        toCamelCase(str, false, " ")             "twoWords"  
"fooBar"  "piñataCafé"
    * camel_Snake      toDelimitedCase(str, false, '_')         "two_Words" 
"foo_Bar" "pinata_Cafe"
    * flatcase         toPascalCase(str).toLowerCase()          "twowords"  
"foobar"  "pinatacafe"
    * kebab-case       toKebabCase(str)                         "two-words" 
"foo-bar" "pinata-cafe"
    * PascalCase       toPascalCase(str)                        "TwoWords"  
"FooBar"  "PinataCafe"
    * PascalCase       toCamelCase(str, true, " ")              "TwoWords"  
"FooBar"  "PiñataCafé"
    * SCREAMINGCASE    toPascalCase(str).toUpperCase()          "TWOWORDS"  
"FOOBAR"  "PINATACAFE"
    * SCREAMING-KEBAB  toDelimitedCase(str, '-').toUpperCase()  "TWO-WORDS" 
"FOO-BAR" "PINATA-CAFE"
    * SCREAMING_SNAKE  toDelimitedCase(str, '_').toUpperCase()  "TWO_WORDS" 
"FOO_BAR" "PINATA_CAFE"
    * snake_case       toSnakeCase(str)                         "two_words" 
"foo_bar" "pinata_cafe"
    * Title_Case       toDelimitedCase(str, '_')                "Two_Words" 
"Foo_Bar" "Pinata_Cafe"
    * Train-Case       toDelimitedCase(str, '-')                "Two-Words" 
"Foo-Bar" "Pinata-Cafe"
    ```
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to