Package org.kiwiproject.beta.base
Class KiwiStrings2
- java.lang.Object
-
- org.kiwiproject.beta.base.KiwiStrings2
-
@Beta public final class KiwiStrings2 extends Object
Utilities related to strings.These utilities could be considered for kiwi's
KiwiStringsclass. Or somewhere else. Or nowhere.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcamelToSnakeCase(String value)Convert a camelCase value to snake_case.static Optional<String>camelToSnakeCaseOrEmpty(@Nullable String value)Convert a camelCase value to snake_case.static StringcamelToSnakeCaseOrNull(@Nullable String value)Convert a camelCase value to snake_case.static StringreplaceNullCharacters(@Nullable String str, String replacement, @Nullable String defaultValue)Replace null characters (Unicode U+0000) instrwith the given replacement string.static StringreplaceNullCharactersWithEmpty(@Nullable String str)Replace null characters (Unicode U+0000) instrwith an empty string.
-
-
-
Method Detail
-
camelToSnakeCase
public static String camelToSnakeCase(String value)
Convert a camelCase value to snake_case.- Parameters:
value- the camelCase value, must not be blank- Returns:
- the converted snake_case value
- Throws:
IllegalArgumentException- if value is blank
-
camelToSnakeCaseOrEmpty
public static Optional<String> camelToSnakeCaseOrEmpty(@Nullable String value)
Convert a camelCase value to snake_case.- Parameters:
value- the camelCase value- Returns:
- Optional containing the converted snake_case value, or an empty Optional if the input value is blank
-
camelToSnakeCaseOrNull
public static String camelToSnakeCaseOrNull(@Nullable String value)
Convert a camelCase value to snake_case.- Parameters:
value- the camelCase value- Returns:
- the converted snake_case value, or null if the input value is blank
-
replaceNullCharactersWithEmpty
public static String replaceNullCharactersWithEmpty(@Nullable String str)
Replace null characters (Unicode U+0000) instrwith an empty string.- Parameters:
str- the string to replace within- Returns:
- a string with null characters replaced, or the original string if no null characters exist in it
-
replaceNullCharacters
public static String replaceNullCharacters(@Nullable String str, String replacement, @Nullable String defaultValue)
Replace null characters (Unicode U+0000) instrwith the given replacement string. If the input string is null, thne the default value is returned.- Parameters:
str- the string to replace withinreplacement- the replacement stringdefaultValue- the value to return ifstris null- Returns:
- a string with null characters replaced, or the original string if no null characters exist in it
-
-