Package io.opentelemetry.api.internal
Class StringUtils
- java.lang.Object
-
- io.opentelemetry.api.internal.StringUtils
-
@Immutable public final class StringUtils extends java.lang.ObjectUtilities for working with strings.This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.
-
-
Constructor Summary
Constructors Modifier Constructor Description privateStringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisNullOrEmpty(java.lang.String string)Returnstrueif the given string is null or is the empty string.private static booleanisPrintableChar(char ch)static booleanisPrintableString(java.lang.String str)Determines whether theStringcontains only printable characters.static java.lang.StringpadLeft(java.lang.String value, int minLength)Pads a given string on the left with leading 0's up the length.private static java.lang.StringpadStart(java.lang.String string, int minLength, char padChar)Returns a string, of length at leastminLength, consisting ofstringprepended with as many copies ofpadCharas are necessary to reach that length.
-
-
-
Method Detail
-
isNullOrEmpty
@Contract("null -> true") public static boolean isNullOrEmpty(@Nullable java.lang.String string)
Returnstrueif the given string is null or is the empty string.This method was copied verbatim from Guava library method com.google.common.base.Strings#isNullOrEmpty(java.lang.String).
- Parameters:
string- a string reference to check- Returns:
trueif the string is null or is the empty string
-
padLeft
public static java.lang.String padLeft(java.lang.String value, int minLength)Pads a given string on the left with leading 0's up the length.- Parameters:
value- the string to padminLength- the minimum length the resulting padded string must have. Can be zero or negative, in which case the input string is always returned.- Returns:
- the padded string
-
padStart
private static java.lang.String padStart(java.lang.String string, int minLength, char padChar)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.This method was copied almost verbatim from Guava library method com.google.common.base.Strings#padStart(java.lang.String, int, char).
- 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
-
isPrintableString
public static boolean isPrintableString(java.lang.String str)
Determines whether theStringcontains only printable characters.- Parameters:
str- theStringto be validated.- Returns:
- whether the
Stringcontains only printable characters.
-
isPrintableChar
private static boolean isPrintableChar(char ch)
-
-