java.lang.Object
io.aiven.commons.util.strings.CasedString.StringCase
- Enclosing class:
CasedString
An enumeration of supported string cases. These cases tag strings as having a specific format.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final CasedString.StringCaseCamel case tags strings like 'CamelCase' or 'camelCase'.static final CasedString.StringCaseDot case tags phrases of words like 'phrase.case'.static final CasedString.StringCaseKebab case tags strings like 'kebab-case'.static final CasedString.StringCaseCamel case tags strings like 'PascalCase' or 'pascalCase'.static final CasedString.StringCasePhrase case tags phrases of words like 'phrase case'.static final CasedString.StringCaseSlash case tags phrases of words like 'phrase.case'.static final CasedString.StringCaseSnake case tags strings like 'Snake_Case'. -
Constructor Summary
ConstructorsConstructorDescriptionStringCase(String name, char delimiter) Create a simple string case for the delimiter.StringCase(String name, Predicate<Character> splitter, boolean preserveSplit, Function<String[], String> joiner) Defines a String Case.StringCase(String name, Predicate<Character> splitter, boolean preserveSplit, Function<String[], String> joiner, Function<String, String> postProcess) Defines a String Case. -
Method Summary
Modifier and TypeMethodDescriptionCreates a cased string from a collection of segments.String[]getSegments(String string) Returns an array of each of the segments in this CasedString.simpleJoiner(char delimiter) Creates a function to join a String array with a character delimiter.toString()
-
Field Details
-
CAMEL
Camel case tags strings like 'CamelCase' or 'camelCase'. This conversion forces the first character to lower case. If the first character is desired to be upper case use PASCAL case instead. -
PASCAL
Camel case tags strings like 'PascalCase' or 'pascalCase'. This conversion forces the first character to upper case. If the first character is desired to be lower case use CAMEL case instead. -
SNAKE
Snake case tags strings like 'Snake_Case'. This conversion does not change the capitalization of any characters in the string. If specific capitalization is required useString.toUpperCase(),String.toLowerCase(), or the commons-text methodsWordUtils.capitalize(String), orWordUtils.uncapitalize(String)as required. -
KEBAB
Kebab case tags strings like 'kebab-case'. This conversion does not change the capitalization of any characters in the string. If specific capitalization is required useString.toUpperCase(),String.toLowerCase(), * or the commons-text methodsWordUtils.capitalize(String), orWordUtils.uncapitalize(String)as required. -
PHRASE
Phrase case tags phrases of words like 'phrase case'. This conversion does not change the capitalization of any characters in the string. If specific capitalization is required useString.toUpperCase(),String.toLowerCase(), * or the commons-text methodsWordUtils.capitalize(String), orWordUtils.uncapitalize(String)as required. -
DOT
Dot case tags phrases of words like 'phrase.case'. This conversion does not change the capitalization of any characters in the string. If specific capitalization is required useString.toUpperCase(),String.toLowerCase(), * or the commons-text methodsWordUtils.capitalize(String), orWordUtils.uncapitalize(String)as required. -
SLASH
Slash case tags phrases of words like 'phrase.case'. This conversion does not change the capitalization of any characters in the string. If specific capitalization is required useString.toUpperCase(),String.toLowerCase(), * or the commons-text methodsWordUtils.capitalize(String), orWordUtils.uncapitalize(String)as required.
-
-
Constructor Details
-
StringCase
public StringCase(String name, Predicate<Character> splitter, boolean preserveSplit, Function<String[], String> joiner) Defines a String Case.- Parameters:
name- The name of the string casesplitter- The predicate that determines when a new word in the cased string begins.preserveSplit- iftruethe character that the splitter detected is preserved as the first character of the new word.joiner- The function to merge a list of strings into the cased String.
-
StringCase
Create a simple string case for the delimiter. Items will be split on the delimiter. Arrays of strings will be joined by the delimiter, null strings will be discarded.- Parameters:
name- the name of the case.delimiter- the delimiter
-
StringCase
public StringCase(String name, Predicate<Character> splitter, boolean preserveSplit, Function<String[], String> joiner, Function<String, String> postProcess) Defines a String Case.- Parameters:
name- The name of the string casesplitter- The predicate that determines when a new word in the cased string begins.preserveSplit- iftruethe character that the splitter detected is preserved as the first character of the new word.joiner- The function to merge a list of strings into the cased String.postProcess- A function to perform post split processing on the generated String array.
-
-
Method Details
-
simpleJoiner
Creates a function to join a String array with a character delimiter. Null strings are discarded. Empty strings will be processed and result in leading or trailing delimiters (if at the start or end of the array) or extra delimiters in other positions.- Parameters:
delimiter- the character to join the string array with.- Returns:
- the function to perform the array join.
-
toString
-
assemble
Creates a cased string from a collection of segments.- Parameters:
segments- the segments to create the CasedString from.- Returns:
- a CasedString
-
getSegments
Returns an array of each of the segments in this CasedString. Segments are defined as the strings between the separators in the CasedString. For the CAMEL case the segments are determined by the presence of a capital letter.- Parameters:
string- The string to parse into segments.- Returns:
- the array of Strings that are segments of the cased string.
-