Class TitleCaseSanitizer
java.lang.Object
io.github.rabinarayanpatra.sanitizer.builtin.TitleCaseSanitizer
- All Implemented Interfaces:
FieldSanitizer<String>
Sanitizer that converts the input string to title case by capitalizing the
first character of each word and lowercasing the rest.
Leading and trailing whitespace is trimmed first. If the input is
null or blank, it is returned as-is.
String input = " heLLo WoRLd ";
String sanitized = new TitleCaseSanitizer().sanitize(input); // "Hello World"
- Since:
- 1.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
TitleCaseSanitizer
public TitleCaseSanitizer()Default constructor.
-
-
Method Details
-
sanitize
Converts a trimmed string to title case (capitalizes the first letter of each word, lowercases the rest).- Specified by:
sanitizein interfaceFieldSanitizer<String>- Parameters:
input- the string to sanitize- Returns:
- the title-cased string, or the original input if it is
nullor blank
-