Package org.nanonative.nano.helper
Class NanoUtils
java.lang.Object
org.nanonative.nano.helper.NanoUtils
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Contextstatic StackTraceElementcallerInfo(Class<?> source) static StringcallerInfoStr(Class<?> source) static byte[]decodeDeflate(byte[] data) static byte[]decodeGzip(byte[] data) static byte[]decodeZip(byte[] data) static byte[]encodeDeflate(byte[] data) static byte[]encodeGzip(byte[] data) static StringformatDuration(long milliseconds) static StringgenerateNanoName(String format) static StringgetThreadName(ExecutorService executorService) static voidhandleJavaError(Supplier<Context> context, Throwable error) Handles a Java error by logging it and shutting down the application.static booleanstatic ContextreadConfigFile(Context context, String path) static ContextreadConfigFiles(Context context, String profile) static ContextreadProfiles(Context result) static ContextresolvePlaceHolders(Context context) static String[]static voidtryExecute(Supplier<Context> context, ExRunnable operation) static voidtryExecute(Supplier<Context> context, ExRunnable operation, Consumer<Throwable> consumer) static booleanwaitForCondition(BooleanSupplier condition) Waits for a condition to become true, with actions on success or timeout.static booleanwaitForCondition(BooleanSupplier condition, long timeout) Waits for a condition to become true, with actions on success or timeout.
-
Field Details
-
LINE_SEPARATOR
-
random
-
NANO_NAMES
-
-
Method Details
-
hasText
-
formatDuration
-
waitForCondition
Waits for a condition to become true, with actions on success or timeout.- Parameters:
condition- The condition to wait for, returning true when met.- Returns:
- true if the condition was met within the timeout, false otherwise.
-
waitForCondition
Waits for a condition to become true, with actions on success or timeout.- Parameters:
condition- The condition to wait for, returning true when met.timeout- stops waiting after period of time to unblock the test.- Returns:
- true if the condition was met within the timeout, false otherwise.
-
split
-
callerInfoStr
-
callerInfo
-
getThreadName
-
readConfigFiles
-
readProfiles
-
readConfigFile
-
addConfig
-
resolvePlaceHolders
-
encodeGzip
public static byte[] encodeGzip(byte[] data) -
decodeZip
public static byte[] decodeZip(byte[] data) -
decodeGzip
public static byte[] decodeGzip(byte[] data) -
encodeDeflate
public static byte[] encodeDeflate(byte[] data) -
decodeDeflate
public static byte[] decodeDeflate(byte[] data) -
generateNanoName
-
handleJavaError
Handles a Java error by logging it and shutting down the application. Note: it's likely that the application won't handle OOM errors. For OOM seeContext.CONFIG_OOM_SHUTDOWN_THRESHOLD.- Parameters:
context- The context to use for logging and shutting down the application.error- The error to handle.
-
tryExecute
-
tryExecute
public static void tryExecute(Supplier<Context> context, ExRunnable operation, Consumer<Throwable> consumer)
-