public final class UtilityElf extends Object
Modifier and Type | Class and Description |
---|---|
static class |
UtilityElf.DefaultThreadFactory |
Constructor and Description |
---|
UtilityElf() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
createInstance(String className,
Class<T> clazz,
Object... args)
Create and instance of the specified class using the constructor matching the specified
arguments.
|
static ThreadPoolExecutor |
createThreadPoolExecutor(BlockingQueue<Runnable> queue,
String threadName,
ThreadFactory threadFactory,
RejectedExecutionHandler policy)
Create a ThreadPoolExecutor.
|
static ThreadPoolExecutor |
createThreadPoolExecutor(int queueSize,
String threadName,
ThreadFactory threadFactory,
RejectedExecutionHandler policy)
Create a ThreadPoolExecutor.
|
static String |
getNullIfEmpty(String text)
Check whether the provided String is empty or
null and return a
null in either case, otherwise return the trimmed String. |
static int |
getTransactionIsolation(String transactionIsolationName)
Get the int value of a transaction isolation level by name.
|
static boolean |
isJdk8Plus()
Are we running on JDK 8 or above?
|
static void |
quietlySleep(long millis)
Sleep and transform an InterruptedException into a RuntimeException.
|
public static String getNullIfEmpty(String text)
null
and return a
null
in either case, otherwise return the trimmed String.text
- the String to check for emptinesspublic static void quietlySleep(long millis)
millis
- the number of milliseconds to sleeppublic static <T> T createInstance(String className, Class<T> clazz, Object... args)
T
- the class typeclassName
- the name of the class to instantiateclazz
- a class to cast the result asargs
- arguments to a constructorpublic static ThreadPoolExecutor createThreadPoolExecutor(int queueSize, String threadName, ThreadFactory threadFactory, RejectedExecutionHandler policy)
queueSize
- the queue sizethreadName
- the thread namethreadFactory
- an optional ThreadFactorypolicy
- the RejectedExecutionHandler policypublic static ThreadPoolExecutor createThreadPoolExecutor(BlockingQueue<Runnable> queue, String threadName, ThreadFactory threadFactory, RejectedExecutionHandler policy)
queue
- the BlockingQueue to usethreadName
- the thread namethreadFactory
- an optional ThreadFactorypolicy
- the RejectedExecutionHandler policypublic static int getTransactionIsolation(String transactionIsolationName)
transactionIsolationName
- the name of the transaction isolation levelpublic static boolean isJdk8Plus()
Copyright © 2017 Zaxxer.com. All Rights Reserved.