Class BootstrapUtils

java.lang.Object
net.microfalx.boot.BootstrapUtils

public class BootstrapUtils extends Object
Various utilities.
  • Constructor Details

    • BootstrapUtils

      public BootstrapUtils()
  • Method Details

    • requireNonNull

      public static <T> T requireNonNull(T value)
      Checks that the specified object reference is not null.
      Type Parameters:
      T - the type of the reference
      Parameters:
      value - the object reference to check for nullity
      Returns:
      obj if not null
      Throws:
      NullPointerException - if obj is null
    • formatBytes

      public static String formatBytes(long value)
      Formats a number of bytes.
      Parameters:
      value - the number
      Returns:
      the formatted number
    • isEmpty

      public static boolean isEmpty(CharSequence value)
      Returns whether the string is empty.
      Parameters:
      value - the string to validate
      Returns:
      true if empty, @{code false} otherwise
    • isNotEmpty

      public static boolean isNotEmpty(CharSequence value)
      Returns whether the string is not empty.
      Parameters:
      value - the string to validate
      Returns:
      true if empty, @{code false} otherwise
    • validateDirectoryExists

      public static File validateDirectoryExists(File directory)
      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

      public static <T> T throwException(Throwable exception)
      Rethrow a checked exception
      Parameters:
      exception - an exception
    • getStackTrace

      public static String getStackTrace(Throwable throwable)
      Dumps an exception stacktrace as a string.
      Parameters:
      throwable - an exception
      Returns:
      exception stacktrace, N/A if null