public final class CommonUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
createNewClassInstance(Class<T> cls,
Class<?>[] ctorClassArgs,
Object[] ctorArgs)
Creates new instance of a class by calling a constructor that receives ctorClassArgs arguments.
|
static long |
getCurrentMs() |
static <T> String |
listToString(List<T> list)
Converts a list of objects to a string.
|
static void |
sleepMs(org.slf4j.Logger logger,
long timeMs)
Sleeps for the given number of milliseconds, reporting interruptions using the given logger.
|
static void |
sleepMs(org.slf4j.Logger logger,
long timeMs,
boolean shouldInterrupt)
Sleeps for the given number of milliseconds, reporting interruptions using the given logger,
and optionally pass the interruption to the caller.
|
static void |
sleepMs(long timeMs)
Sleeps for the given number of milliseconds.
|
static String[] |
toStringArray(ArrayList<String> src)
Parses
ArrayList<String> into String[]. |
static void |
warmUpLoop()
Common empty loop utility that serves the purpose of warming up the JVM before performance
microbenchmarks.
|
public static long getCurrentMs()
public static <T> String listToString(List<T> list)
T - type of the objectslist - list of objectspublic static String[] toStringArray(ArrayList<String> src)
ArrayList<String> into String[].src - is the ArrayList of stringspublic static void sleepMs(long timeMs)
timeMs - sleep duration in millisecondspublic static void sleepMs(org.slf4j.Logger logger,
long timeMs)
logger - logger for reporting interruptionstimeMs - sleep duration in millisecondspublic static void sleepMs(org.slf4j.Logger logger,
long timeMs,
boolean shouldInterrupt)
logger - logger for reporting interruptionstimeMs - sleep duration in millisecondsshouldInterrupt - determines if interruption should be passed to the callerpublic static void warmUpLoop()
public static <T> T createNewClassInstance(Class<T> cls, Class<?>[] ctorClassArgs, Object[] ctorArgs) throws InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, InvocationTargetException
cls - the class to createctorClassArgs - parameters type list of the constructor to initiate, if null default
constructor will be calledctorArgs - the arguments to pass the constructorInstantiationException - if the instantiation failsIllegalAccessException - if the constructor cannot be accessedNoSuchMethodException - if the constructor does not existSecurityException - if security violation has occurredInvocationTargetException - if the constructor invocation results in an exceptionCopyright © 2015. All Rights Reserved.