Package org.nanonative.nano.helper
Class NanoUtils
java.lang.Object
org.nanonative.nano.helper.NanoUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longstatic final Stringstatic final longstatic final longstatic final longstatic final String[][]static final longprotected static Randomstatic final longstatic final long[]static final String[]static final longstatic final longstatic final long -
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 nanos) 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 <T extends Throwable>
TreduceSte(T throwable) 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
-
IGNORED_TRACE
-
NS
public static final long NS- See Also:
-
US
public static final long US- See Also:
-
MS
public static final long MS- See Also:
-
S
public static final long S- See Also:
-
M
public static final long M- See Also:
-
H
public static final long H- See Also:
-
D
public static final long D- See Also:
-
W
public static final long W- See Also:
-
MO
public static final long MO- See Also:
-
Y
public static final long Y- See Also:
-
UNIT_NS
public static final long[] UNIT_NS -
UNIT_SY
-
-
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) -
listFiles
-
reduceSte
-