Package com.oracle.bmc.util.internal
Enum StringUtils
- java.lang.Object
-
- java.lang.Enum<StringUtils>
-
- com.oracle.bmc.util.internal.StringUtils
-
- All Implemented Interfaces:
Serializable
,Comparable<StringUtils>
public enum StringUtils extends Enum<StringUtils>
String manipulation utilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
contains(String s, String searchStr)
Return true if the string contains the search string, or false if either is null.static boolean
containsIgnoreCase(String s, String searchStr)
Return true if the string contains the search string, ignoring case, or false if either is null.static boolean
equalsIgnoreCase(String s1, String s2)
Null-safe case-insensitive equals.static boolean
isAllBlank(String... strings)
Returns true if all of the strings passed in are blank, as determined by isBlank.static boolean
isAnyBlank(String... strings)
Returns true if any of the strings passed in are blank, as determined by isBlank.static boolean
isBlank(String s)
Return true if this string is either null or just whitespace.static boolean
isEmpty(String s)
Returns true if the string is empty.static boolean
isNoneBlank(String... strings)
Returns true if none of the strings passed in are blank, as determined by isBlank.static boolean
isNotBlank(String s)
Return true if this string is not null and not just whitespace.static boolean
isNotEmpty(String s)
Returns true if the string is not empty.static String
join(Collection<?> objects, String delimiter)
Join the collection of objects to a string.static String
left(String s, int length)
Return the first length characters of the string.static int
length(String s)
Return the length of the string, or 0 if the string is null.static String
random(int length, String allowed)
Returns a string of the requested length, made up of characters from the allowed string.static String
randomAlphabetic(int length)
Returns a string of random alphabetic characters of the requested length.static String
randomAlphabetic(int minLengthInclusive, int maxLengthExclusive)
Returns a string of random alphabetic characters at least minLengthInclusive characters and less than maxLengthExclusive characters long.static String
randomPrint(int length)
Returns a string of random printable characters of the requested length.static String
randomPrint(int minLengthInclusive, int maxLengthExclusive)
Returns a string of random printable characters at least minLengthInclusive characters and less than maxLengthExclusive characters long.static String
repeat(String substring, int count)
Repeat the substring count times.static String
replace(String template, Map<String,String> replacements, String prefix, String suffix)
Replace the placeholders in the template with the values in the replacement mapping.static String
upperCase(String s)
Returns the string in uppercase, or null if it was nullstatic StringUtils
valueOf(String name)
Returns the enum constant of this type with the specified name.static StringUtils[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Method Detail
-
values
public static StringUtils[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (StringUtils c : StringUtils.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static StringUtils valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
isBlank
public static boolean isBlank(String s)
Return true if this string is either null or just whitespace.- Parameters:
s
- the string- Returns:
- true if this string is either null or just whitespace.
-
isNotBlank
public static boolean isNotBlank(String s)
Return true if this string is not null and not just whitespace.- Parameters:
s
- the string- Returns:
- true if this string is not null and not just whitespace.
-
join
public static String join(Collection<?> objects, String delimiter)
Join the collection of objects to a string.Objects that are null are represented by the empty string.
- Parameters:
objects
- collection of objectsdelimiter
- delimiter between the objects- Returns:
- joined string
-
replace
public static String replace(String template, Map<String,String> replacements, String prefix, String suffix)
Replace the placeholders in the template with the values in the replacement mapping.- Parameters:
template
- template stringreplacements
- map from key to replacement valueprefix
- prefix of the placeholdersuffix
- suffix of the placeholder- Returns:
- replaced string
-
randomPrint
public static String randomPrint(int minLengthInclusive, int maxLengthExclusive)
Returns a string of random printable characters at least minLengthInclusive characters and less than maxLengthExclusive characters long.The characters have ASCII codes ranging from 32 to 125 (both inclusive) and include spaces.
- Parameters:
minLengthInclusive
- minimum length (inclusive)maxLengthExclusive
- maximum length (exclusive)- Returns:
- the random string
-
randomPrint
public static String randomPrint(int length)
Returns a string of random printable characters of the requested length.The characters have ASCII codes ranging from 32 to 125 (both inclusive) and include spaces.
- Parameters:
length
- length in characters- Returns:
- the random string
-
randomAlphabetic
public static String randomAlphabetic(int minLengthInclusive, int maxLengthExclusive)
Returns a string of random alphabetic characters at least minLengthInclusive characters and less than maxLengthExclusive characters long.The characters range from 'A' - 'Z' or from 'a' - 'z' (all inclusive).
- Parameters:
minLengthInclusive
- minimum length (inclusive)maxLengthExclusive
- maximum length (exclusive)- Returns:
- the random string
-
randomAlphabetic
public static String randomAlphabetic(int length)
Returns a string of random alphabetic characters of the requested length.The characters range from 'A' - 'Z' or from 'a' - 'z' (all inclusive).
- Parameters:
length
- length in characters- Returns:
- the random string
-
random
public static String random(int length, String allowed)
Returns a string of the requested length, made up of characters from the allowed string.- Parameters:
length
- length in charactersallowed
- string with allowed characters- Returns:
- the random string
-
isAnyBlank
public static boolean isAnyBlank(String... strings)
Returns true if any of the strings passed in are blank, as determined by isBlank.- Parameters:
strings
- strings to check- Returns:
- true if any of the strings are blank
-
isNoneBlank
public static boolean isNoneBlank(String... strings)
Returns true if none of the strings passed in are blank, as determined by isBlank.- Parameters:
strings
- strings to check- Returns:
- true if none of the strings are blank
-
isAllBlank
public static boolean isAllBlank(String... strings)
Returns true if all of the strings passed in are blank, as determined by isBlank.- Parameters:
strings
- strings to check- Returns:
- true if all of the strings are blank
-
isNotEmpty
public static boolean isNotEmpty(String s)
Returns true if the string is not empty.- Parameters:
s
- string to check- Returns:
- true if not empty
-
isEmpty
public static boolean isEmpty(String s)
Returns true if the string is empty.- Parameters:
s
- string to check- Returns:
- true if empty
-
upperCase
public static String upperCase(String s)
Returns the string in uppercase, or null if it was null- Parameters:
s
- string to convert to uppercase- Returns:
- string in uppercase, or null if it was null
-
left
public static String left(String s, int length)
Return the first length characters of the string.- Parameters:
s
- stringlength
- number of characters- Returns:
- first s
-
length
public static int length(String s)
Return the length of the string, or 0 if the string is null.- Parameters:
s
- string- Returns:
- length of string or 0 if string is null
-
containsIgnoreCase
public static boolean containsIgnoreCase(String s, String searchStr)
Return true if the string contains the search string, ignoring case, or false if either is null.- Parameters:
s
- stringsearchStr
- substring to search for- Returns:
- true if the string contains the search string, or false if either is null
-
equalsIgnoreCase
public static boolean equalsIgnoreCase(String s1, String s2)
Null-safe case-insensitive equals.- Parameters:
s1
- first strings2
- second string- Returns:
- true if equals, ignoring case
-
contains
public static boolean contains(String s, String searchStr)
Return true if the string contains the search string, or false if either is null.- Parameters:
s
- stringsearchStr
- substring to search for- Returns:
- true if the string contains the search string, or false if either is null
-
-