Package org.forgerock.util
Class Strings
- java.lang.Object
-
- org.forgerock.util.Strings
-
public final class Strings extends Object
Common utility methods for Strings.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Enum<T>>
TasEnum(String value, Class<T> type)Returns the string value as an enum constant of the specified enum type.static booleanisBlank(CharSequence charSeq)Check to see if a character sequence is null or blank.static booleanisNullOrEmpty(String value)Check to see if the provided String isnullor empty.static voidjoinAsString(StringBuilder builder, String separator, Iterable<?> values)Appends into the providedStringBuilderthe string representation of the objects contained in the provided iterable concatenated together using the provided separator.static voidjoinAsString(StringBuilder builder, String separator, Object... values)Appends into the providedStringBuilderthe string representation of the provided objects concatenated together using the provided separator.static StringjoinAsString(String separator, Iterable<?> values)Returns a string whose content is the string representation of the objects contained in the provided iterable concatenated together using the provided separator.static StringjoinAsString(String separator, Object... values)Returns a string whose content is the string representation of the provided objects concatenated together using the provided separator.
-
-
-
Method Detail
-
joinAsString
public static String joinAsString(String separator, Object... values)
Returns a string whose content is the string representation of the provided objects concatenated together using the provided separator.- Parameters:
separator- The separator string.values- The objects to be joined.- Returns:
- A string whose content is the string representation of the provided objects concatenated together using the provided separator.
- Throws:
NullPointerException- Ifvaluesorseparatorwerenull.
-
joinAsString
public static String joinAsString(String separator, Iterable<?> values)
Returns a string whose content is the string representation of the objects contained in the provided iterable concatenated together using the provided separator.- Parameters:
separator- The separator string.values- The iterable whose elements are to be joined.- Returns:
- A string whose content is the string representation of the objects contained in the provided iterable concatenated together using the provided separator.
- Throws:
NullPointerException- Ifseparatororvalueswerenull.
-
joinAsString
public static void joinAsString(StringBuilder builder, String separator, Object... values)
Appends into the providedStringBuilderthe string representation of the provided objects concatenated together using the provided separator.- Parameters:
builder- The String builder where to append.separator- The separator string.values- The objects to be joined.- Throws:
NullPointerException- Ifbuilder,separatororvalueswerenull.
-
joinAsString
public static void joinAsString(StringBuilder builder, String separator, Iterable<?> values)
Appends into the providedStringBuilderthe string representation of the objects contained in the provided iterable concatenated together using the provided separator.- Parameters:
builder- The String builder where to append.separator- The separator string.values- The iterable whose elements are to be joined.- Throws:
NullPointerException- Ifbuilder,separatororvalueswerenull.
-
asEnum
public static <T extends Enum<T>> T asEnum(String value, Class<T> type)
Returns the string value as an enum constant of the specified enum type. The string value and enum constants are compared, ignoring case considerations. If the string value isnull, this method returnsnull.- Type Parameters:
T- the enum type sub-class.- Parameters:
value- the string valuetype- the enum type to match constants with the value.- Returns:
- the enum constant represented by the string value.
- Throws:
IllegalArgumentException- iftypedoes not represent an enum type, of ifvaluedoes not match one of the enum constantsNullPointerException- iftypeisnull.
-
isNullOrEmpty
public static boolean isNullOrEmpty(String value)
Check to see if the provided String isnullor empty.- Parameters:
value- The value to check.- Returns:
trueif the value is eithernullor is empty.
-
isBlank
public static boolean isBlank(CharSequence charSeq)
Check to see if a character sequence is null or blank.- Parameters:
charSeq- Sequence to test (String is also a CharSequence)- Returns:
- true if the char sequence is null or blank.
-
-