Class StringUtils


  • public final class StringUtils
    extends Object
    • Method Detail

      • isBlank

        public static boolean isBlank​(String str)
        Determine if the supplied String is blank (i.e., null or consisting only of whitespace characters).
        Parameters:
        str - the string to check; may be null
        Returns:
        true if the string is blank
        See Also:
        isNotBlank(String)
      • isNotBlank

        public static boolean isNotBlank​(String str)
        Determine if the supplied String is not blank.
        Parameters:
        str - the string to check; may be null
        Returns:
        true if the string is not blank
        See Also:
        isBlank(String)
      • substringMatch

        public static boolean substringMatch​(CharSequence str,
                                             int index,
                                             CharSequence substring)
        Test whether the given string matches the given substring at the given index.
        Parameters:
        str - the original string (or StringBuilder)
        index - the index in the original string to start matching against
        substring - the substring to match at the given index
      • camelToSplitName

        public static String camelToSplitName​(String camelName,
                                              String split)
      • nullSafeToString

        public static String nullSafeToString​(Object obj)
        Convert the supplied Object to a String using the following algorithm.
        • If the supplied object is null, this method returns "null".
        • If the supplied object is a primitive array, the appropriate Arrays#toString(...) variant will be used to convert it to a String.
        • If the supplied object is an object array, Arrays#deepToString(Object[]) will be used to convert it to a String.
        • Otherwise, toString() will be invoked on the object. If the result is non-null, that result will be returned. If the result is null, "null" will be returned.
        • If any of the above results in an exception, this method delegates to defaultToString(Object)
        Parameters:
        obj - the object to convert to a String; may be null
        Returns:
        a String representation of the supplied object; never null
        See Also:
        Arrays.deepToString(Object[]), ClassUtil.nullSafeToString(Class...)
      • defaultToString

        public static String defaultToString​(Object obj)
        Convert the supplied Object to a default String representation using the following algorithm.
        • If the supplied object is null, this method returns "null".
        • Otherwise, the String returned by this method will be generated analogous to the default implementation of Object.toString() by using the supplied object's class name and hash code as follows: obj.getClass().getName() + "@" + Integer.toHexString(System.identityHashCode(obj))
        Parameters:
        obj - the object to convert to a String; may be null
        Returns:
        the default String representation of the supplied object; never null
        See Also:
        nullSafeToString(Object), ClassUtil.nullSafeToString(Class...)