Package com.sap.cds.services.utils
Class StringUtils
java.lang.Object
com.sap.cds.services.utils.StringUtils
Helper functions providing simple
String operations-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanCompares two string property maps.static booleanTests if aStringhas content (e.g.static StringReturns the first not emptyStringfrom the parameters ornullif not existing.static StringstringifyList(List<String> values) Converts a list of values to a string 'value1, value2, ...'static StringstringifyMap(Map<String, Object> keyValueMap) Converts a map of key value pairs to a string 'key1=value1, key2=value2, ...'static StringtoStringSafely(Object[] args) Converts an array of objects into a string, while catching and handling all exception types.static StringTrims a string from a certain character
-
Method Details
-
isEmpty
Tests if aStringhas content (e.g. none space characters) or not.- Parameters:
value- The string to be tested- Returns:
truein casevalueisnullor has no content.
-
notEmpty
Returns the first not emptyStringfrom the parameters ornullif not existing.- Parameters:
values- TheStringvalues in sorted order- Returns:
- The first not empty
Stringornull
-
trim
Trims a string from a certain character- Parameters:
value- the stringc- the character- Returns:
- the trimmed string
-
equalsMapIgnoreCase
Compares two string property maps. The keys are compared case-insensitive. Values are compared case-sensitive.- Parameters:
props- map to be comparedotherProps- map to be compared- Returns:
trueid equals andfalseotherwise
-
stringifyMap
Converts a map of key value pairs to a string 'key1=value1, key2=value2, ...'- Parameters:
keyValueMap- map containing key value pairs- Returns:
- string representation
-
stringifyList
Converts a list of values to a string 'value1, value2, ...'- Parameters:
values- list of values to stringify- Returns:
- string representation
-
toStringSafely
Converts an array of objects into a string, while catching and handling all exception types.- Parameters:
args- the array of objects- Returns:
- the stringified objects
-