Class Utils


  • public abstract class Utils
    extends Object
    A placeholder class for miscellaneous utility methods.
    Author:
    [email protected]
    • Constructor Detail

      • Utils

        public Utils()
    • Method Detail

      • lazySupplier

        public static <T> Supplier<T> lazySupplier​(Supplier<T> supplier)
        A lazy initialization wrapper for Supplier
        Parameters:
        supplier - Supplier to lazy-initialize
        Returns:
        lazy wrapped supplier
      • addHyphensToUuid

        public static String addHyphensToUuid​(String uuid)
        Requires an input uuid string Encoded as 32 hex characters. For example cced093a76eea418ffdc9bb9a6453df3
        Parameters:
        uuid - string encoded as 32 hex characters.
        Returns:
        uuid string encoded in 8-4-4-4-12 (rfc4122) format.
      • convertToUuidString

        @Nullable
        public static String convertToUuidString​(@Nullable
                                                 String id)
        Method converts a string Id to UUID. This Method specifically converts id's with less than 32 digit hex characters into UUID format (See RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace) by left padding id with Zeroes and adding hyphens. It assumes that if the input id contains hyphens it is already an UUID. Please don't use this method to validate/guarantee your id as an UUID.
        Parameters:
        id - a string encoded in hex characters.
        Returns:
        a UUID string.
      • csvToList

        @Nonnull
        public static List<String> csvToList​(@Nullable
                                             String inputString)
        Creates an iterator over values a comma-delimited string.
        Parameters:
        inputString - input string
        Returns:
        iterator
      • getBuildVersion

        public static String getBuildVersion()
        Attempts to retrieve build.version from system build properties.
        Returns:
        build version as string
      • getJavaVersion

        public static String getJavaVersion()
        Returns current java runtime version information (name/vendor/version) as a string.
        Returns:
        java runtime version as string
      • getLocalHostName

        public static String getLocalHostName()
        Makes a best-effort attempt to resolve the hostname for the local host.
        Returns:
        name for localhost
      • isWavefrontResponse

        public static boolean isWavefrontResponse​(@Nonnull
                                                  javax.ws.rs.core.Response response)
        Check if the HTTP 407/408 response was actually received from Wavefront - if it's a JSON object containing "code" key, with value equal to the HTTP response code, it's most likely from us.
        Parameters:
        response - Response object.
        Returns:
        whether we consider it a Wavefront response
      • throwAny

        public static <E extends Throwable> E throwAny​(Throwable t)
                                                throws E extends Throwable
        Use this to throw checked exceptions from iterator methods that do not declare that they throw checked exceptions.
        Throws:
        E extends Throwable