Class StringUtils
java.lang.Object
com.sap.cloud.sdk.cloudplatform.util.StringUtils
Internal utility class for common String operations.
- Since:
- 5.21.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringcapitalize(String s) Capitalizes the first character of the given string.static booleanendsWithIgnoreCase(String str, String suffix) Checks if the given string ends with the specified suffix, ignoring case.static booleanChecks if the given CharSequence is blank or empty.static booleanChecks if the given string is blank.static booleanChecks if the given string is empty.static StringprependIfMissing(String s, String prefix) Prepends the specified prefix to the string if it does not already start with that prefix, ignoring case.static StringremoveEndIgnoreCase(String s, String prefix) Removes the specified suffix from the end of the string, ignoring case.static StringremoveStartIgnoreCase(String s, String prefix) Removes the specified prefix from the start of the string, ignoring case.static booleanstartsWithIgnoreCase(String str, String prefix) Checks if the given string starts with the specified prefix, ignoring case.static StringsubstringBefore(String string, char suffix) Returns the substring of the given string before the first occurrence of the specified suffix character.static StringtrimToNull(String s) Trims the given string and returns null if the result is empty.static StringUncapitalizes the first character of the given string.
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
startsWithIgnoreCase
Checks if the given string starts with the specified prefix, ignoring case.- Parameters:
str- the string to checkprefix- the prefix to look for- Returns:
- true if the string starts with the prefix, ignoring case; false otherwise
-
endsWithIgnoreCase
Checks if the given string ends with the specified suffix, ignoring case.- Parameters:
str- the string to checksuffix- the suffix to look for- Returns:
- true if the string ends with the suffix, ignoring case; false otherwise
-
removeStartIgnoreCase
Removes the specified prefix from the start of the string, ignoring case.- Parameters:
s- the string to modifyprefix- the prefix to remove- Returns:
- the modified string with the prefix removed, or the original string if it did not start with the prefix;
-
removeEndIgnoreCase
Removes the specified suffix from the end of the string, ignoring case.- Parameters:
s- the string to modifyprefix- the suffix to remove- Returns:
- the modified string with the suffix removed, or the original string if it did not end with the suffix;
-
isBlank
Checks if the given string is blank.- Parameters:
s- the string to check- Returns:
- true if the string is null, empty, or contains only whitespace characters; false otherwise
-
isEmpty
Checks if the given string is empty.- Parameters:
s- the string to check- Returns:
- true if the string is null, or empty (""); false otherwise
-
isBlank
Checks if the given CharSequence is blank or empty.- Parameters:
s- the CharSequence to check- Returns:
- true if the CharSequence is null, empty, or contains only whitespace characters; false otherwise
-
capitalize
Capitalizes the first character of the given string.- Parameters:
s- the string to capitalize- Returns:
- the string with the first character capitalized, or null if the input is null or empty
-
uncapitalize
Uncapitalizes the first character of the given string.- Parameters:
s- the string to uncapitalize- Returns:
- the string with the first character uncapitalized, or null if the input is null or empty
-
trimToNull
Trims the given string and returns null if the result is empty.- Parameters:
s- the string to trim- Returns:
- the trimmed string, or null if the input is null or empty after trimming
-
prependIfMissing
Prepends the specified prefix to the string if it does not already start with that prefix, ignoring case.- Parameters:
s- the string to modifyprefix- the prefix to prepend- Returns:
- the modified string with the prefix prepended if it was not already present; otherwise, the original string
-
substringBefore
Returns the substring of the given string before the first occurrence of the specified suffix character.- Parameters:
string- the string to searchsuffix- the character to search for- Returns:
- the substring before the first occurrence of the suffix character, or the original string if the suffix is not found;
-