类 StringUtils

java.lang.Object
spring.turbo.util.StringUtils

public final class StringUtils extends Object
String 相关工具
从以下版本开始:
1.0.0
作者:
应卓
另请参阅:
  • 方法详细资料

    • isEmpty

      public static boolean isEmpty(@Nullable String string)
      判断字符串是否为空串
      参数:
      string - 字符串
      返回:
      判断结果
    • isNotEmpty

      public static boolean isNotEmpty(@Nullable String string)
      判断字符串是否不为空串
      参数:
      string - 字符串
      返回:
      判断结果
    • isBlank

      public static boolean isBlank(@Nullable String string)
      判断字符串是否为空白串
      参数:
      string - 字符串
      返回:
      判断结果
    • isNotBlank

      public static boolean isNotBlank(@Nullable String string)
      判断字符串是否不为空白串
      参数:
      string - 字符串
      返回:
      判断结果
    • length

      public static int length(@Nullable String string)
      获取字符串的长度
      参数:
      string - 字符串
      返回:
      长度
    • containsWhitespace

      public static boolean containsWhitespace(String string)
      判断字符串是否包含白字符
      参数:
      string - 字符串
      返回:
      判断结果
    • containsAnyChars

      public static boolean containsAnyChars(String string, String charsToCheck)
      判断字符串是否包含任意一个指定的字符
      参数:
      string - 字符串
      charsToCheck - 需要检查的字符集
      返回:
      检测结果
    • containsAllChars

      public static boolean containsAllChars(String string, String charsToCheck)
      判断字符串是否包含所有的指定的字符
      参数:
      string - 字符串
      charsToCheck - 需要检查的字符集
      返回:
      检测结果
    • containsNoneChars

      public static boolean containsNoneChars(String string, String charsToCheck)
      判断字符串是否不包含任意一个指定的字符
      参数:
      string - 字符串
      charsToCheck - 需要检查的字符集
      返回:
      检测结果
    • countMatches

      public static int countMatches(String string, char ch)
      字符出现个数计数
      参数:
      string - 字符串
      ch - 要查找的字符
      返回:
      结果
    • deleteWhitespace

      public static String deleteWhitespace(String string)
      删除白字符
      参数:
      string - 字符串
      返回:
      结果
    • deleteChars

      public static String deleteChars(String string, String charsToDelete)
      删除字符串中的指定字符
      参数:
      string - 字符串
      charsToDelete - 待删除的字符集合
      返回:
      结果
    • toCharStream

      public static Stream<Character> toCharStream(@Nullable String string)
      字符串转换为字符Stream
      参数:
      string - 字符串
      返回:
      实例
    • toCharList

      public static List<Character> toCharList(@Nullable String string)
      字符串转换为字符List
      参数:
      string - 字符串
      返回:
      实例
    • toCharSet

      public static Set<Character> toCharSet(@Nullable String string)
      字符串转换为字符Set
      参数:
      string - 字符串
      返回:
      实例
    • reverse

      public static String reverse(String string)
      字符串逆向
      参数:
      string - 字符串
      返回:
      结果
    • commaDelimitedListToStringArray

      public static String[] commaDelimitedListToStringArray(@Nullable String string)
      逗号分隔字符串转化成字符串数组
      参数:
      string - 逗号分隔的字符串
      返回:
      结果
    • commaDelimitedListToStringArray

      public static String[] commaDelimitedListToStringArray(@Nullable String string, boolean trimAllElements)
      逗号分隔字符串转化成字符串数组
      参数:
      string - 逗号分隔的字符串
      trimAllElements - 是否trim所有的子字符串
      返回:
      结果
    • capitalize

      public static String capitalize(String string)
      首字母大写
      参数:
      string - 字符串
      返回:
      结果
      另请参阅:
    • uncapitalize

      public static String uncapitalize(String string)
      取消首字母大写
      参数:
      string - 字符串
      返回:
      结果
      另请参阅:
    • nullSafeAdd

      public static void nullSafeAdd(Collection<String> collection, @Nullable String element)
      null 字符串加入集合
      参数:
      collection - 集合
      element - 字符串
    • nullSafeAddAll

      public static void nullSafeAddAll(Collection<String> collection, @Nullable String... elements)
      null 字符串加入集合
      参数:
      collection - 集合
      elements - 字符串(多个)
    • nullSafeAddAll

      public static void nullSafeAddAll(Collection<String> collection, @Nullable Collection<String> elements)
      null 字符串加入集合
      参数:
      collection - 集合
      elements - 字符串(多个)
    • emptySafeAdd

      public static void emptySafeAdd(Collection<String> collection, @Nullable String element)
      非空字符串加入集合
      参数:
      collection - 集合
      element - 字符串
    • emptySafeAddAll

      public static void emptySafeAddAll(Collection<String> collection, @Nullable String... elements)
      非空字符串加入集合
      参数:
      collection - 集合
      elements - 字符串(多个)
    • emptySafeAddAll

      public static void emptySafeAddAll(Collection<String> collection, @Nullable Collection<String> elements)
      非空字符串加入集合
      参数:
      collection - 集合
      elements - 字符串(多个)
    • blankSafeAdd

      public static void blankSafeAdd(Collection<String> collection, @Nullable String element)
      非空白字符串加入集合
      参数:
      collection - 集合
      element - 字符串
    • blankSafeAddAll

      public static void blankSafeAddAll(Collection<String> collection, @Nullable String... elements)
      非空白字符串加入集合
      参数:
      collection - 集合
      elements - 字符串(多个)
    • blankSafeAddAll

      public static void blankSafeAddAll(Collection<String> collection, @Nullable Collection<String> elements)
      非空白字符串加入集合
      参数:
      collection - 集合
      elements - 字符串(多个)
    • nullSafeJoin

      public static String nullSafeJoin(@Nullable Iterable<?> elements, @Nullable String separator)
      多个元素拼接成一个字符串 (忽略null元素)
      参数:
      elements - 多个元素
      separator - 分隔符
      返回:
      结果
    • nullSafeJoin

      public static String nullSafeJoin(@Nullable Iterator<?> elements, @Nullable String separator)
      多个元素拼接成一个字符串 (忽略null元素)
      参数:
      elements - 多个元素
      separator - 分隔符
      返回:
      结果
    • nullSafeJoin

      public static String nullSafeJoin(@Nullable Object[] elements, @Nullable String separator)
      多个元素拼接成一个字符串 (忽略null元素)
      参数:
      elements - 多个元素
      separator - 分隔符
      返回:
      结果
    • nullSafeJoin

      public static String nullSafeJoin(@Nullable String[] elements, @Nullable String separator)
      多个元素拼接成一个字符串 (忽略null元素)
      参数:
      elements - 多个元素
      separator - 分隔符
      返回:
      结果
    • startsWith

      public static boolean startsWith(@Nullable String string, String prefix)
      判断一个字符串是否有指定的前缀
      参数:
      string - 字符串
      prefix - 前缀
      返回:
      结果
    • endsWith

      public static boolean endsWith(@Nullable String string, String suffix)
      判断一个字符串是否有指定的后缀
      参数:
      string - 字符串
      suffix - 后缀
      返回:
      结果
    • startsWithIgnoreCase

      public static boolean startsWithIgnoreCase(@Nullable String string, String prefix)
      判断一个字符串是否有指定的前缀 (大小写不敏感)
      参数:
      string - 字符串
      prefix - 前缀
      返回:
      结果
    • endsWithIgnoreCase

      public static boolean endsWithIgnoreCase(@Nullable String string, String suffix)
      判断一个字符串是否有指定的后缀 (大小写不敏感)
      参数:
      string - 字符串
      suffix - 后缀
      返回:
      结果
    • repeat

      public static String repeat(String string, int n)
      重复字符串
      参数:
      string - 字符串
      n - 重复的次数
      返回:
      结果
    • compare

      public static int compare(@Nullable String string1, @Nullable String string2)
      比较两个字符串
      参数:
      string1 - 字符串1
      string2 - 字符串2
      返回:
      结果
    • compare

      public static int compare(@Nullable String string1, @Nullable String string2, boolean nullIsLess)
      比较两个字符串
      参数:
      string1 - 字符串1
      string2 - 字符串2
      nullIsLess - 为truenull排在前面
      返回:
      结果
    • compareIgnoreCase

      public static int compareIgnoreCase(@Nullable String string1, @Nullable String string2)
      比较两个字符串 (大小写不敏感)
      参数:
      string1 - 字符串1
      string2 - 字符串2
      返回:
      结果
    • compareIgnoreCase

      public static int compareIgnoreCase(@Nullable String string1, @Nullable String string2, boolean nullIsLess)
      比较两个字符串 (大小写不敏感)
      参数:
      string1 - 字符串1
      string2 - 字符串2
      nullIsLess - 为truenull排在前面
      返回:
      结果
    • firstNonEmpty

      @Nullable public static String firstNonEmpty(@Nullable String... strings)
      查找第一个非Empty字符串
      参数:
      strings - 字符串组
      返回:
      结果或 null
    • firstNonBlank

      @Nullable public static String firstNonBlank(@Nullable String... values)
      查找第一个非Blank字符串
      参数:
      values - 字符串组
      返回:
      结果或 null