Class RequireUtils

java.lang.Object
org.sejda.commons.util.RequireUtils

public final class RequireUtils extends Object
Utility methods to check parameters and conditions validity.
Author:
Andrea Vacondio
  • Method Details

    • requireNotNullArg

      public static void requireNotNullArg(Object arg, String exceptionMessage)
      Throws an IllegalArgumentException if the given argument is null
      Parameters:
      arg -
      exceptionMessage -
    • requireArg

      public static void requireArg(boolean condition, String exceptionMessage)
      Throws an IllegalArgumentException if the given condition is not met
      Parameters:
      condition -
      exceptionMessage -
    • requireNotBlank

      public static void requireNotBlank(String value, String exceptionMessage)
      Throws an IllegalArgumentException if the given string is blank
      Parameters:
      value - string
      exceptionMessage -
    • requireIOCondition

      public static void requireIOCondition(boolean condition, String exceptionMessage) throws IOException
      Throws an IOException if the given condition is not met
      Parameters:
      condition -
      exceptionMessage -
      Throws:
      IOException
    • requireState

      public static void requireState(boolean condition, String exceptionMessage)
      Throws an IllegalStateException if the given condition is not met
      Parameters:
      condition -
      exceptionMessage -
      Throws:
      IllegalStateException
    • requireNotNegative

      public static void requireNotNegative(int victim)
      Throws an IllegalArgumentException if the input value is a negative integer
      Parameters:
      victim -
    • require

      public static <E extends Throwable> void require(boolean condition, Supplier<? extends E> supplier) throws E
      Throws the Exception supplied by the supplier in case the condition is not met
      Parameters:
      condition -
      supplier -
      Throws:
      Throwable