Class StringUtils

java.lang.Object
io.opentelemetry.api.internal.StringUtils

@Immutable public final class StringUtils extends 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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Returns true if the given string is null or is the empty string.
    private static boolean
    isPrintableChar(char ch)
     
    static boolean
    Determines whether the String contains only printable characters.
    static String
    padLeft(String value, int minLength)
    Pads a given string on the left with leading 0's up the length.
    private static String
    padStart(String string, int minLength, char padChar)
    Returns a string, of length at least minLength, consisting of string prepended with as many copies of padChar as are necessary to reach that length.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StringUtils

      private StringUtils()
  • Method Details

    • isNullOrEmpty

      @Contract("null -> true") public static boolean isNullOrEmpty(@Nullable String string)
      Returns true 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 String padLeft(String value, int minLength)
      Pads a given string on the left with leading 0's up the length.
      Parameters:
      value - the string to pad
      minLength - 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 String padStart(String string, int minLength, char padChar)
      Returns a string, of length at least minLength, consisting of string prepended with as many copies of padChar 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 result
      minLength - 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(String str)
      Determines whether the String contains only printable characters.
      Parameters:
      str - the String to be validated.
      Returns:
      whether the String contains only printable characters.
    • isPrintableChar

      private static boolean isPrintableChar(char ch)