Class StringUtils

java.lang.Object
com.sap.cds.services.utils.StringUtils

public class StringUtils extends Object
Helper functions providing simple String operations
  • Method Details

    • isEmpty

      public static boolean isEmpty(String value)
      Tests if a String has content (e.g. none space characters) or not.
      Parameters:
      value - The string to be tested
      Returns:
      true in case value is null or has no content.
    • notEmpty

      public static String notEmpty(String... values)
      Returns the first not empty String from the parameters or null if not existing.
      Parameters:
      values - The String values in sorted order
      Returns:
      The first not empty String or null
    • trim

      public static String trim(String value, char c)
      Trims a string from a certain character
      Parameters:
      value - the string
      c - the character
      Returns:
      the trimmed string
    • equalsMapIgnoreCase

      public static boolean equalsMapIgnoreCase(Map<String,String> props, Map<String,String> otherProps)
      Compares two string property maps. The keys are compared case-insensitive. Values are compared case-sensitive.
      Parameters:
      props - map to be compared
      otherProps - map to be compared
      Returns:
      true id equals and false otherwise
    • stringifyMap

      public static String stringifyMap(Map<String,Object> keyValueMap)
      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

      public static String stringifyList(List<String> values)
      Converts a list of values to a string 'value1, value2, ...'
      Parameters:
      values - list of values to stringify
      Returns:
      string representation
    • toStringSafely

      public static String toStringSafely(Object[] args)
      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