Package org.openapitools.codegen.utils
Class StringUtils
- java.lang.Object
-
- org.openapitools.codegen.utils.StringUtils
-
public class StringUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
NAME_CACHE_EXPIRY_PROPERTY
Set the cache expiry (in seconds) of the sanitizedNameCache, camelizedWordsCache and underscoreWordsCache.static String
NAME_CACHE_SIZE_PROPERTY
Set the cache size (entry count) of the sanitizedNameCache, camelizedWordsCache and underscoreWordsCache.
-
Constructor Summary
Constructors Constructor Description StringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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.javastatic String
camelize(String inputWord, CamelizeOption camelizeOption)
Camelize name (parameter, property, method, etc)static String
dashize(String word)
Dashize the given word.static String
escape(String name, Map<String,String> replacementMap, List<String> charactersToAllow, String appendToReplacement)
Return the name with escaped characters.static String
getUniqueString(Set<String> processedStrings, String input)
Return a unique string based on a set of processed strings.static String
underscore(String word)
Underscore the given word.
-
-
-
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
-
-
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 camelizecamelizeOption
- 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 escapedreplacementMap
- map of replacement characters for non-allowed characterscharactersToAllow
- characters that are not escapedappendToReplacement
- String to append to replaced characters.- Returns:
- the escaped word
throws Runtime exception as word is not escaped properly.
-
-