Package com.google.common.base
Class Strings
java.lang.Object
com.google.common.base.Strings
Deprecated.
The Google Guava Core Libraries are deprecated and will not be part of the AEM SDK after April 2023
Static utility methods pertaining to
String or CharSequence
instances.- Since:
- 3.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringDeprecated.Returns the longest stringprefixsuch thata.toString().startsWith(prefix) && b.toString().startsWith(prefix), taking care not to split surrogate pairs.static StringDeprecated.Returns the longest stringsuffixsuch thata.toString().endsWith(suffix) && b.toString().endsWith(suffix), taking care not to split surrogate pairs.static StringemptyToNull(String string) Deprecated.Returns the given string if it is nonempty;nullotherwise.static booleanisNullOrEmpty(String string) Deprecated.Returnstrueif the given string is null or is the empty string.static StringnullToEmpty(String string) Deprecated.Returns the given string if it is non-null; the empty string otherwise.static StringDeprecated.Returns a string, of length at leastminLength, consisting ofstringappended with as many copies ofpadCharas are necessary to reach that length.static StringDeprecated.Returns a string, of length at leastminLength, consisting ofstringprepended with as many copies ofpadCharas are necessary to reach that length.static StringDeprecated.Returns a string consisting of a specific number of concatenated copies of an input string.
-
Method Details
-
nullToEmpty
Deprecated.Returns the given string if it is non-null; the empty string otherwise.- Parameters:
string- the string to test and possibly return- Returns:
stringitself if it is non-null;""if it is null
-
emptyToNull
Deprecated.Returns the given string if it is nonempty;nullotherwise.- Parameters:
string- the string to test and possibly return- Returns:
stringitself if it is nonempty;nullif it is empty or null
-
isNullOrEmpty
Deprecated.Returnstrueif the given string is null or is the empty string.Consider normalizing your string references with
nullToEmpty(java.lang.String). If you do, you can useString.isEmpty()instead of this method, and you won't need special null-safe forms of methods likeString.toUpperCase(java.util.Locale)either. Or, if you'd like to normalize "in the other direction," converting empty strings tonull, you can useemptyToNull(java.lang.String).- Parameters:
string- a string reference to check- Returns:
trueif the string is null or is the empty string
-
padStart
Deprecated.Returns a string, of length at leastminLength, consisting ofstringprepended with as many copies ofpadCharas are necessary to reach that length. For example,padStart("7", 3, '0')returns"007"padStart("2010", 3, '0')returns"2010"
See
Formatterfor a richer set of formatting capabilities.- Parameters:
string- the string which should appear at the end of the resultminLength- the minimum length the resulting string must have. Can be zero or negative, in which case the input string is always returned.padChar- the character to insert at the beginning of the result until the minimum length is reached- Returns:
- the padded string
-
padEnd
Deprecated.Returns a string, of length at leastminLength, consisting ofstringappended with as many copies ofpadCharas are necessary to reach that length. For example,padEnd("4.", 5, '0')returns"4.000"padEnd("2010", 3, '!')returns"2010"
See
Formatterfor a richer set of formatting capabilities.- Parameters:
string- the string which should appear at the beginning of the resultminLength- the minimum length the resulting string must have. Can be zero or negative, in which case the input string is always returned.padChar- the character to append to the end of the result until the minimum length is reached- Returns:
- the padded string
-
repeat
Deprecated.Returns a string consisting of a specific number of concatenated copies of an input string. For example,repeat("hey", 3)returns the string"heyheyhey".- Parameters:
string- any non-null stringcount- the number of times to repeat it; a nonnegative integer- Returns:
- a string containing
stringrepeatedcounttimes (the empty string ifcountis zero) - Throws:
IllegalArgumentException- ifcountis negative
-
commonPrefix
Deprecated.Returns the longest stringprefixsuch thata.toString().startsWith(prefix) && b.toString().startsWith(prefix), taking care not to split surrogate pairs. Ifaandbhave no common prefix, returns the empty string.- Since:
- 11.0
-
commonSuffix
Deprecated.Returns the longest stringsuffixsuch thata.toString().endsWith(suffix) && b.toString().endsWith(suffix), taking care not to split surrogate pairs. Ifaandbhave no common suffix, returns the empty string.- Since:
- 11.0
-