Class StringUtils

java.lang.Object
org.citrusframework.util.StringUtils

public class StringUtils extends Object
Utility helper class for Strings.
  • Field Details

  • Method Details

    • hasText

      public static boolean hasText(String str)
      Helper method checks for non-null and non-blank String.
    • hasNoText

      public static boolean hasNoText(String str)
      Helper method checks for null or blank String.
    • isEmpty

      public static boolean isEmpty(String str)
      String helper checking for isEmpty String and adds null check on given parameter.
    • isNotEmpty

      public static boolean isNotEmpty(String str)
      String helper checking for isEmpty String and adds null check on given parameter.
    • appendSegmentToUrlPath

      public static String appendSegmentToUrlPath(String path, String segment)
      Appends a URL segment to an existing URL path.

      This method ensures that the provided segment is appended correctly to the base path, handling cases where there may or may not be existing separators (`/`). It avoids duplicate separators and ensures proper formatting of the resulting URL.

      Parameters:
      path - the base URL path to which the segment will be appended. If null, the segment will be returned.
      segment - the segment to append to the base path. If null, the original path will be returned.
      Returns:
      the combined URL path with the appended segment, properly formatted.
    • quote

      public static String quote(String text, boolean quote)
    • trimTrailingComma

      public static void trimTrailingComma(StringBuilder builder)
      Trims trailing whitespace characters and the first trailing comma from the end of the given StringBuilder.

      This method removes all trailing whitespace characters (such as spaces, tabs, and newline characters) and the first trailing comma found from the end of the content in the provided StringBuilder. Any additional commas or whitespace characters after the first trailing comma are not removed.

      Parameters:
      builder - the StringBuilder whose trailing whitespace characters and first comma are to be removed
    • convertFirstCharToUpperCase

      public static String convertFirstCharToUpperCase(String input)
      Converts the first letter of the given input string to uppercase while leaving the rest of the string unchanged. If the input string is empty or null, an empty string is returned.
      Parameters:
      input - The string to be converted. It can be null or empty.
      Returns:
      the string in with upper case first letter
    • convertFirstCharToLowerCase

      public static String convertFirstCharToLowerCase(String input)
      Converts the first letter of the given input string to lowercase while leaving the rest of the string unchanged. If the input string is empty or null, an empty string is returned.
      Parameters:
      input - The string to be converted. It can be null or empty.
      Returns:
      the string in with upper case first letter
    • normalizeWhitespace

      public static String normalizeWhitespace(String text, boolean normalizeWhitespace, boolean normalizeLineEndingsToUnix)
      Normalizes the given text by replacing all whitespace characters (identified by {@link Character#isWhitespace) by a single space and replacing windows style line endings with unix style line endings.