Package com.applitools.utils
Class ArgumentGuard
- java.lang.Object
-
- com.applitools.utils.ArgumentGuard
-
public class ArgumentGuard extends Object
Argument validation utilities.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidgreaterThanOrEqualToZero(long param, String paramName)Fails if the input integer parameter is negative.static voidgreaterThanZero(double param, String paramName)Fails if the input integer parameter is below or equal to 0.static voidgreaterThanZero(long param, String paramName)Fails if the input integer parameter is smaller than 1.static voidisNull(Object param, String paramName)Fails if the input parameter is not null.static voidisValidState(boolean isValid, String errMsg)Fails if isValid is false.static <T> voidnotContainsNull(Iterable<T> param, String paramName)Fails if the input iterable contains null elements.static <T> voidnotContainsNull(T[] param, String paramName)Fails if the input array has contains elements.static voidnotEqual(Object param, Object value, String paramName)Fails if the input parameter equals the input value.static voidnotNull(Object param, String paramName)Fails if the input parameter is null.static voidnotNullOrEmpty(String param, String paramName)Fails if the input parameter string is null or empty.static voidnotOfType(Object param, Class paramExpectedClass, String paramName)Fails if param is not of the expected type.static voidnotZero(long param, String paramName)Fails if the input integer parameter is equal to 0.
-
-
-
Method Detail
-
notNull
public static void notNull(Object param, String paramName) throws IllegalArgumentException
Fails if the input parameter is null.- Parameters:
param- The input parameterparamName- The input parameter name- Throws:
IllegalArgumentException
-
notContainsNull
public static <T> void notContainsNull(Iterable<T> param, String paramName) throws IllegalArgumentException
Fails if the input iterable contains null elements.- Type Parameters:
T- The type parameter- Parameters:
param- The input parameterparamName- The input parameter name- Throws:
IllegalArgumentException
-
notContainsNull
public static <T> void notContainsNull(T[] param, String paramName) throws IllegalArgumentExceptionFails if the input array has contains elements.- Type Parameters:
T- The type parameter- Parameters:
param- The input parameterparamName- The input parameter name- Throws:
IllegalArgumentException
-
notEqual
public static void notEqual(Object param, Object value, String paramName)
Fails if the input parameter equals the input value.- Parameters:
param- The input parametervalue- The input valueparamName- The input parameter name
-
notNullOrEmpty
public static void notNullOrEmpty(String param, String paramName) throws IllegalArgumentException
Fails if the input parameter string is null or empty.- Parameters:
param- The input parameter.paramName- The input parameter name.- Throws:
IllegalArgumentException
-
isNull
public static void isNull(Object param, String paramName) throws IllegalArgumentException
Fails if the input parameter is not null.- Parameters:
param- The input parameter.paramName- The input parameter name.- Throws:
IllegalArgumentException
-
greaterThanOrEqualToZero
public static void greaterThanOrEqualToZero(long param, String paramName) throws IllegalArgumentExceptionFails if the input integer parameter is negative.- Parameters:
param- The input parameter.paramName- The input parameter name.- Throws:
IllegalArgumentException
-
greaterThanZero
public static void greaterThanZero(long param, String paramName) throws IllegalArgumentExceptionFails if the input integer parameter is smaller than 1.- Parameters:
param- The input parameter.paramName- The input parameter name.- Throws:
IllegalArgumentException
-
greaterThanZero
public static void greaterThanZero(double param, String paramName) throws IllegalArgumentExceptionFails if the input integer parameter is below or equal to 0.- Parameters:
param- The input parameter.paramName- The input parameter name.- Throws:
IllegalArgumentException
-
notZero
public static void notZero(long param, String paramName) throws IllegalArgumentExceptionFails if the input integer parameter is equal to 0.- Parameters:
param- The input parameter.paramName- The input parameter name.- Throws:
IllegalArgumentException
-
isValidState
public static void isValidState(boolean isValid, String errMsg) throws IllegalStateExceptionFails if isValid is false.- Parameters:
isValid- Whether the current state is valid.errMsg- A description of the error.- Throws:
IllegalStateException
-
notOfType
public static void notOfType(Object param, Class paramExpectedClass, String paramName) throws IllegalArgumentException
Fails if param is not of the expected type.- Parameters:
param- The input parameterparamExpectedClass- The expected type.paramName- The input parameter name.- Throws:
IllegalArgumentException
-
-