Package io.opentelemetry.api.internal
Class StringUtils
- java.lang.Object
-
- io.opentelemetry.api.internal.StringUtils
-
@Immutable public final class StringUtils extends java.lang.Object
Utilities 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 private
StringUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
isNullOrEmpty(java.lang.String string)
Returnstrue
if the given string is null or is the empty string.private static boolean
isPrintableChar(char ch)
static boolean
isPrintableString(java.lang.String str)
Determines whether theString
contains only printable characters.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.private static java.lang.String
padStart(java.lang.String string, int minLength, char padChar)
Returns a string, of length at leastminLength
, consisting ofstring
prepended with as many copies ofpadChar
as are necessary to reach that length.
-
-
-
Method Detail
-
isNullOrEmpty
@Contract("null -> true") public static boolean isNullOrEmpty(@Nullable java.lang.String string)
Returnstrue
if 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:
true
if 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 ofstring
prepended with as many copies ofpadChar
as are necessary to reach that length. For example,padStart("7", 3, '0')
returns"007"
padStart("2010", 3, '0')
returns"2010"
See
Formatter
for 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 theString
contains only printable characters.- Parameters:
str
- theString
to be validated.- Returns:
- whether the
String
contains only printable characters.
-
isPrintableChar
private static boolean isPrintableChar(char ch)
-
-