Class StringUtils


  • public class StringUtils
    extends Object
    • Field Detail

      • NAME_CACHE_SIZE_PROPERTY

        public static final String NAME_CACHE_SIZE_PROPERTY
        Set the cache size (entry count) of the sanitizedNameCache, camelizedWordsCache and underscoreWordsCache.
        See Also:
        Constant Field Values
      • NAME_CACHE_EXPIRY_PROPERTY

        public static final String NAME_CACHE_EXPIRY_PROPERTY
        Set the cache expiry (in seconds) of the sanitizedNameCache, camelizedWordsCache and underscoreWordsCache.
        See Also:
        Constant Field Values
    • Constructor Detail

      • StringUtils

        public StringUtils()
    • Method Detail

      • underscore

        public static String underscore​(String word)
        Underscore the given word. Copied from Twitter elephant bird https://github.com/twitter/elephant-bird/blob/master/core/src/main/java/com/twitter/elephantbird/util/Strings.java
        Parameters:
        word - The word
        Returns:
        The underscored version of the word
      • dashize

        public static String dashize​(String word)
        Dashize the given word.
        Parameters:
        word - The word
        Returns:
        The dashized version of the word, e.g. "my-name"
      • camelize

        public static String camelize​(String word)
        Camelize name (parameter, property, method, etc) with upper case for first letter copied from Twitter elephant bird https://github.com/twitter/elephant-bird/blob/master/core/src/main/java/com/twitter/elephantbird/util/Strings.java
        Parameters:
        word - string to be camelize
        Returns:
        camelized string
      • camelize

        public static String camelize​(String inputWord,
                                      CamelizeOption camelizeOption)
        Camelize name (parameter, property, method, etc)
        Parameters:
        inputWord - string to be camelize
        camelizeOption - option for the camelize result
        Returns:
        camelized string
      • escape

        public static String escape​(String name,
                                    Map<String,​String> replacementMap,
                                    List<String> charactersToAllow,
                                    String appendToReplacement)
        Return the name with escaped characters.
        Parameters:
        name - the name to be escaped
        replacementMap - map of replacement characters for non-allowed characters
        charactersToAllow - characters that are not escaped
        appendToReplacement - String to append to replaced characters.
        Returns:
        the escaped word

        throws Runtime exception as word is not escaped properly.