Class CaseFormatUtils


  • public class CaseFormatUtils
    extends java.lang.Object
    Utility class for conversion between different case formats
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String WORD_SEPARATOR_REGEX  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private CaseFormatUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String adjustWordCase​(java.lang.String s, boolean firstLetterUpperCased)  
      private static java.util.List<java.lang.String> extractWords​(java.lang.String s)  
      private static boolean isAllCaps​(java.lang.String s)  
      static java.lang.String toCamelCase​(java.lang.String s)
      Converts an input string into camelCase.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • WORD_SEPARATOR_REGEX

        private static final java.lang.String WORD_SEPARATOR_REGEX
        See Also:
        Constant Field Values
    • Constructor Detail

      • CaseFormatUtils

        private CaseFormatUtils()
    • Method Detail

      • toCamelCase

        public static java.lang.String toCamelCase​(java.lang.String s)
        Converts an input string into camelCase.

        The input string may use any of the well known case styles: Pascal, Snake, Kebab or even Camel. Already camelCased strings will be returned as is. Mix and match is also an option; the algorithm will try its best to give an acceptable answer. Mixed case will be preserved, i.e assertThat(toCamelCase("miXedCAse")).isEqualTo("miXedCAse")

        Parameters:
        s - the string to be converted
        Returns:
        the input string converted to camelCase
      • extractWords

        private static java.util.List<java.lang.String> extractWords​(java.lang.String s)
      • adjustWordCase

        private static java.lang.String adjustWordCase​(java.lang.String s,
                                                       boolean firstLetterUpperCased)
      • isAllCaps

        private static boolean isAllCaps​(java.lang.String s)