java.lang.Object
org.sejda.commons.util.RequireUtils
Utility methods to check parameters and conditions validity.
- Author:
- Andrea Vacondio
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends Throwable>
voidThrows the Exception supplied by the supplier in case the condition is not metstatic voidrequireArg(boolean condition, String exceptionMessage) Throws anIllegalArgumentExceptionif the given condition is not metstatic voidrequireIOCondition(boolean condition, String exceptionMessage) Throws anIOExceptionif the given condition is not metstatic voidrequireNotBlank(String value, String exceptionMessage) Throws anIllegalArgumentExceptionif the given string is blankstatic voidrequireNotNegative(int victim) Throws anIllegalArgumentExceptionif the input value is a negative integerstatic voidrequireNotNullArg(Object arg, String exceptionMessage) Throws anIllegalArgumentExceptionif the given argument is nullstatic voidrequireState(boolean condition, String exceptionMessage) Throws anIllegalStateExceptionif the given condition is not met
-
Method Details
-
requireNotNullArg
Throws anIllegalArgumentExceptionif the given argument is null- Parameters:
arg-exceptionMessage-
-
requireArg
Throws anIllegalArgumentExceptionif the given condition is not met- Parameters:
condition-exceptionMessage-
-
requireNotBlank
Throws anIllegalArgumentExceptionif the given string is blank- Parameters:
value- stringexceptionMessage-
-
requireIOCondition
public static void requireIOCondition(boolean condition, String exceptionMessage) throws IOException Throws anIOExceptionif the given condition is not met- Parameters:
condition-exceptionMessage-- Throws:
IOException
-
requireState
Throws anIllegalStateExceptionif the given condition is not met- Parameters:
condition-exceptionMessage-- Throws:
IllegalStateException
-
requireNotNegative
public static void requireNotNegative(int victim) Throws anIllegalArgumentExceptionif 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
-