Class StringUtil

java.lang.Object
jp.ecuacion.lib.core.util.StringUtil

public class StringUtil extends Object
Provides string-related utility methods.
  • Methods which StringUtils in apache-commons-lang has are not implemented in this class. Use StringUtils.
  • The way of implementation follows to the one of apache-commons-lang.
  • Constructor Details

    • StringUtil

      public StringUtil()
  • Method Details

    • getLowerCamelFromSnakeOrNullIfInputIsNull

      @Nullable public String getLowerCamelFromSnakeOrNullIfInputIsNull(@Nullable String snakeCaseString)
      Returns a lowerCamelCase string from a snake case string.
      Parameters:
      snakeCaseString - snakeCaseString, may be null.
      Returns:
      camel case string, may be null when snakeCaseString is null.
    • getUpperCamelFromSnakeOrNullIfInputIsNull

      @Nullable public String getUpperCamelFromSnakeOrNullIfInputIsNull(@Nullable String snakeCaseString)
      Returns a upperCamelCase string from a snake case string.
      Parameters:
      snakeCaseString - snakeCaseString, may be null.
      Returns:
      camel case string, may be null when snakeCaseString is null.
    • getLowerSnakeFromCamel

      @Nullable public String getLowerSnakeFromCamel(@Nullable String camelCaseString)
      Returns a lowerSnakeCase string from a camel case string.
      Parameters:
      camelCaseString - snakeCaseString, may be null.
      Returns:
      camel case string, may be null when camelCaseString is null.
    • toCurrencyFormat

      @Nonnull public String toCurrencyFormat(@Nonnull String number)
      Returns comma-separated number from number.
      Parameters:
      number - number
      Returns:
      String comma-separated number.
      Throws:
      NumberFormatException - NumberFormatException.
    • getCsv

      @Nonnull public String getCsv(@Nonnull String... array)
      Returns csv from string array.
      Parameters:
      array - string array
      Returns:
      csv
    • getCsv

      @Nonnull public String getCsv(@Nonnull Collection<String> collection)
      Returns csv from list of string.
      Parameters:
      collection - collection of string.
      Returns:
      csv.
    • getCsvWithSpace

      @Nonnull public String getCsvWithSpace(@RequireNonnull String[] collection)
      Returns csv with spaces after commas from list of string.

      This is used not for creating csv file, but for logging or program code creation.

      Parameters:
      collection - list of string.
      Returns:
      csv with spaces after commas.
    • getCsvWithSpace

      @Nonnull public String getCsvWithSpace(@Nonnull Collection<String> collection)
      Returns csv with spaces after commas from list of string.

      This is used not for creating csv file, but for logging or program code creation.

      Parameters:
      collection - collection of string.
      Returns:
      csv with spaces after commas.
    • escapeHtml

      @Nonnull public String escapeHtml(@Nonnull String str)
      Returns html-escaped strings.
      Parameters:
      str - string.
      Returns:
      html-escaped strings.