Class StringUtil


  • public class StringUtil
    extends Object
    Author:
    tmoreau
    • Constructor Detail

      • StringUtil

        public StringUtil()
    • Method Detail

      • compareStringLists

        public static boolean compareStringLists​(List<String> list1,
                                                 List<String> list2)
        Compare two lists of strings. TBD - support a form that ignores ordering?
        Parameters:
        list1 -
        list2 -
        Returns:
        boolean indicating if the list of strings have the ssame values in the same order.
      • compareStrings

        public static boolean compareStrings​(String str1,
                                             String str2)
      • compareStringsIgnoreCase

        public static boolean compareStringsIgnoreCase​(String str1,
                                                       String str2)
      • getActionReportMessageParts

        public static List<String> getActionReportMessageParts​(ActionReport actionReport)
        Return the message parts of an action report as a List
        Parameters:
        actionReport -
        Returns:
        List containing actionReport's message parts.
      • getCommaSeparatedStringList

        public static String getCommaSeparatedStringList​(List<String> strings)
        Convert a List to a comma-separated string. This is often used to format strings that are sent to admin commands.
        Parameters:
        strings -
        Returns:
        String a comma-separated string containing strings.
      • parseCommaSeparatedStringList

        public static List<String> parseCommaSeparatedStringList​(String stringList)
        Convert a string containing a comma-separated list of strings into a List. This is often used to parse strings that are returned from admin commands.
        Parameters:
        stringList -
        Returns:
        List containing the strings in stringList.
      • notEmpty

        public static boolean notEmpty​(String string)
        Determines if a string is null/empty or not
        Parameters:
        string -
        Returns:
        true if the string is not null and has a length greater than zero, false otherwise
      • nonEmpty

        public static String nonEmpty​(String string)
        Converts a null/empty/non-empty string to null or non-empty
        Parameters:
        string -
        Returns:
        null if string is null or empty, otherwise returns string
      • nonNull

        public static String nonNull​(String string)
        Converts a null/empty/non-empty string to empty or non-empty
        Parameters:
        string -
        Returns:
        an empty string if string is null or empty, otherwise returns string