Package com.intergral.deep.agent
Class Utils
- java.lang.Object
-
- com.intergral.deep.agent.Utils
-
public final class Utils extends Object
Collection of utilities for general java related tasks.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceUtils.ITrimResultThe result of a trim operation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long[]currentTimeNanos()Get the current time in mills and nanoseconds from epochstatic booleanendsWithIgnoreCase(String str, String suffix)Check if a string ends with a value, ignoring the case.static intgetJavaVersion()Get the current version of Java running in this JVM.static <T> Map<String,T>newMap(Map<String,T> map)Create a new map from the input.static StringthrowableToString(Throwable t)Convert a throwable into a loggable string.static StringtrimPrefix(String str, String prefix)Trim a string from another string.static Utils.ITrimResulttruncate(String str, int maxLength)Trim a string to a specified length.static StringvalueOf(Object obj)This will create a string representation of the object passed in.
-
-
-
Method Detail
-
getJavaVersion
public static int getJavaVersion()
Get the current version of Java running in this JVM.- Returns:
- the java version number
-
currentTimeNanos
public static long[] currentTimeNanos()
Get the current time in mills and nanoseconds from epochLong will wrap when the date exceeds Saturday, 12 April 2262 00:47:16.854 GMT+01:00 DST
- Returns:
- the epoch time in mills and nanos
-
newMap
public static <T> Map<String,T> newMap(Map<String,T> map)
Create a new map from the input.- Type Parameters:
T- the key type- Parameters:
map- the input map- Returns:
- a new map with the same values are the input, or a new empty map
-
endsWithIgnoreCase
public static boolean endsWithIgnoreCase(String str, String suffix)
Check if a string ends with a value, ignoring the case.- Parameters:
str- the string to searchsuffix- the value to serch for- Returns:
- true if
strends withsuffix, disregarding case sensitivity - See Also:
- Source
-
valueOf
public static String valueOf(Object obj)
This will create a string representation of the object passed in.- Parameters:
obj- the value to create a string from- Returns:
- the string form of the object
-
trimPrefix
public static String trimPrefix(String str, String prefix)
Trim a string from another string.- Parameters:
str- the target stringprefix- the value to remove from the string- Returns:
- the new string
-
truncate
public static Utils.ITrimResult truncate(String str, int maxLength)
Trim a string to a specified length.- Parameters:
str- the target stringmaxLength- the max length to make the string- Returns:
- a
Utils.ITrimResult, so we can know if the string was trimmed
-
-