Package net.microfalx.boot
Class BootstrapUtils
java.lang.Object
net.microfalx.boot.BootstrapUtils
Various utilities.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatBytes(long value) Formats a number of bytes.static StringgetStackTrace(Throwable throwable) Dumps an exception stacktrace as a string.static booleanisEmpty(CharSequence value) Returns whether the string is empty.static booleanisNotEmpty(CharSequence value) Returns whether the string is not empty.static <T> TrequireNonNull(T value) Checks that the specified object reference is notnull.static <T> TthrowException(Throwable exception) Rethrow a checked exceptionstatic FilevalidateDirectoryExists(File directory) Validated the directory, creates the directory if it does not exist and fails if the directory cannot be created.
-
Constructor Details
-
BootstrapUtils
public BootstrapUtils()
-
-
Method Details
-
requireNonNull
public static <T> T requireNonNull(T value) Checks that the specified object reference is notnull.- Type Parameters:
T- the type of the reference- Parameters:
value- the object reference to check for nullity- Returns:
objif notnull- Throws:
NullPointerException- ifobjisnull
-
formatBytes
Formats a number of bytes.- Parameters:
value- the number- Returns:
- the formatted number
-
isEmpty
Returns whether the string is empty.- Parameters:
value- the string to validate- Returns:
trueif empty, @{code false} otherwise
-
isNotEmpty
Returns whether the string is not empty.- Parameters:
value- the string to validate- Returns:
trueif empty, @{code false} otherwise
-
validateDirectoryExists
Validated the directory, creates the directory if it does not exist and fails if the directory cannot be created.- Parameters:
directory- the directory- Returns:
- the directory, after validation
-
throwException
Rethrow a checked exception- Parameters:
exception- an exception
-
getStackTrace
Dumps an exception stacktrace as a string.- Parameters:
throwable- an exception- Returns:
- exception stacktrace, N/A if null
-