Package com.wavefront.common
Class Utils
- java.lang.Object
-
- com.wavefront.common.Utils
-
public abstract class Utils extends Object
A placeholder class for miscellaneous utility methods.- Author:
- [email protected]
-
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
addHyphensToUuid(String uuid)
Requires an input uuid string Encoded as 32 hex characters.static String
convertToUuidString(String id)
Method converts a string Id toUUID
.static List<String>
csvToList(String inputString)
Creates an iterator over values a comma-delimited string.static String
getBuildVersion()
Attempts to retrieve build.version from system build properties.static String
getJavaVersion()
Returns current java runtime version information (name/vendor/version) as a string.static String
getLocalHostName()
Makes a best-effort attempt to resolve the hostname for the local host.static boolean
isWavefrontResponse(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.static <T> Supplier<T>
lazySupplier(Supplier<T> supplier)
A lazy initialization wrapper forSupplier
static <E extends Throwable>
EthrowAny(Throwable t)
Use this to throw checked exceptions from iterator methods that do not declare that they throw checked exceptions.
-
-
-
Method Detail
-
lazySupplier
public static <T> Supplier<T> lazySupplier(Supplier<T> supplier)
A lazy initialization wrapper forSupplier
- 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 examplecced093a76eea418ffdc9bb9a6453df3
- 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 toUUID
. 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
-
-