Class SentenceCaseSanitizer

java.lang.Object
io.github.rabinarayanpatra.sanitizer.builtin.SentenceCaseSanitizer
All Implemented Interfaces:
FieldSanitizer<String>

public class SentenceCaseSanitizer extends Object implements FieldSanitizer<String>
Sanitizer that converts the input string to sentence case by capitalizing only the first character 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 SentenceCaseSanitizer().sanitize(input); // "Hello world"
 
 
Since:
1.1.0
See Also:
  • Constructor Details

    • SentenceCaseSanitizer

      public SentenceCaseSanitizer()
      Default constructor.
  • Method Details

    • sanitize

      public @Nullable String sanitize(@Nullable String input)
      Converts a trimmed string to sentence case (capitalizes the first letter, lowercases the rest).
      Specified by:
      sanitize in interface FieldSanitizer<String>
      Parameters:
      input - the string to sanitize
      Returns:
      the sentence-cased string, or the original input if it is null or blank