Package org.glassfish.admin.rest.utils
Class StringUtil
- java.lang.Object
-
- org.glassfish.admin.rest.utils.StringUtil
-
public class StringUtil extends Object
- Author:
- tmoreau
-
-
Constructor Summary
Constructors Constructor Description StringUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
compareStringLists(List<String> list1, List<String> list2)
Compare two lists of strings.static boolean
compareStrings(String str1, String str2)
static boolean
compareStringsIgnoreCase(String str1, String str2)
static List<String>
getActionReportMessageParts(ActionReport actionReport)
Return the message parts of an action report as a Liststatic String
getCommaSeparatedStringList(List<String> strings)
Convert a Listto a comma-separated string. static String
nonEmpty(String string)
Converts a null/empty/non-empty string to null or non-emptystatic String
nonNull(String string)
Converts a null/empty/non-empty string to empty or non-emptystatic boolean
notEmpty(String string)
Determines if a string is null/empty or notstatic List<String>
parseCommaSeparatedStringList(String stringList)
Convert a string containing a comma-separated list of strings into a List.
-
-
-
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.
-
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 Listto 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
-
-