Class LettuceStrings


  • public class LettuceStrings
    extends Object
    Helper for String checks. This class is part of the internal API and may change without further notice.
    Since:
    3.0
    Author:
    Mark Paluch
    • Method Detail

      • isEmpty

        public static boolean isEmpty​(String cs)
        Checks if a String is empty or null.
        Parameters:
        cs - the char sequence
        Returns:
        true if empty
        Since:
        6.0.3
        See Also:
        String.isEmpty()
      • isEmpty

        public static boolean isEmpty​(CharSequence cs)
        Checks if a CharSequence has a length of 0 or null.
        Parameters:
        cs - the char sequence
        Returns:
        true if empty
        See Also:
        CharSequence.length()
      • isNotEmpty

        public static boolean isNotEmpty​(String cs)
        Checks if a String is not empty and not null.
        Parameters:
        cs - the char sequence
        Returns:
        true if not empty
        Since:
        6.0.3
        See Also:
        String.isEmpty()
      • isNotEmpty

        public static boolean isNotEmpty​(CharSequence cs)
        Checks if a CharSequence has a non-zero length and is not null.
        Parameters:
        cs - the char sequence
        Returns:
        true if not empty
        See Also:
        CharSequence.length()
      • string

        public static String string​(double n)
        Convert double to String. If n is infinite, returns positive/negative infinity +inf and -inf.
        Parameters:
        n - the double.
        Returns:
        string representation of n
      • toDouble

        public static double toDouble​(String s)
        Convert String to double. If s is +inf/-inf, returns positive/negative infinity. If s is +nan/-nan, returns NaN.
        Parameters:
        s - string representation of the number
        Returns:
        the double value.
        Since:
        4.3.3
      • arrayToDelimitedString

        public static String arrayToDelimitedString​(Object[] arr,
                                                    String delim)
        Convert a String array into a delimited String (e.g. CSV).

        Useful for toString() implementations.

        Parameters:
        arr - the array to display
        delim - the delimiter to use (typically a ",")
        Returns:
        the delimited String
      • collectionToDelimitedString

        public static String collectionToDelimitedString​(Collection<?> coll,
                                                         String delim,
                                                         String prefix,
                                                         String suffix)
        Convert a Collection to a delimited String (e.g. CSV).

        Useful for toString() implementations.

        Parameters:
        coll - the Collection to convert
        delim - the delimiter to use (typically a ",")
        prefix - the String to start each element with
        suffix - the String to end each element with
        Returns:
        the delimited String
      • toCharArray

        public static char[] toCharArray​(CharSequence seq)
        Return a char[] from the give CharSequence.
        Parameters:
        seq - the sequence to read
        Returns:
        the character array
        Since:
        6.2