Class ArgumentGuard


  • public class ArgumentGuard
    extends Object
    Argument validation utilities.
    • Method Detail

      • 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 parameter
        paramName - The input parameter name
        Throws:
        IllegalArgumentException
      • notContainsNull

        public static <T> void notContainsNull​(T[] param,
                                               String paramName)
                                        throws IllegalArgumentException
        Fails if the input array has contains elements.
        Type Parameters:
        T - The type parameter
        Parameters:
        param - The input parameter
        paramName - 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 parameter
        value - The input value
        paramName - The input parameter name
      • greaterThanOrEqualToZero

        public static void greaterThanOrEqualToZero​(long param,
                                                    String paramName)
                                             throws IllegalArgumentException
        Fails 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 IllegalArgumentException
        Fails 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 IllegalArgumentException
        Fails if the input integer parameter is below or 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 IllegalStateException
        Fails 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 parameter
        paramExpectedClass - The expected type.
        paramName - The input parameter name.
        Throws:
        IllegalArgumentException