Enum Validate

    • Method Detail

      • values

        public static Validate[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Validate c : Validate.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Validate valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • notNull

        public static <T> T notNull​(T o,
                                    String reason,
                                    Object... values)
        Throw NullPointerException if the object is null.
        Parameters:
        o - object that has to be non-null
        reason - exception message
        values - values to be put in placeholders in reason (e.g. “%s”).
        Returns:
        the object
        Throws:
        NullPointerException - if the object is null
      • isInstanceOf

        public static <T> T isInstanceOf​(Class<?> clazz,
                                         T o,
                                         String reason,
                                         Object... values)
        Throw IllegalArgumentException if the object is not an instance of the class.
        Parameters:
        clazz - the class the object has to be
        o - the object
        reason - the exception message
        values - values to be put in placeholders in reason (e.g. “%s”).
        Returns:
        the object
        Throws:
        IllegalArgumentException - if the object is not an instance of the class
      • isTrue

        public static void isTrue​(boolean condition,
                                  String reason,
                                  Object... values)
        Throw IllegalArgumentException if the condition is false.
        Parameters:
        condition - the condition
        reason - exception message
        values - values to be put in placeholders in reason (e.g. “%s”).
        Throws:
        NullPointerException - if the condition is false
      • inclusiveBetween

        public static long inclusiveBetween​(long minimum,
                                            long maximum,
                                            long value,
                                            String reason,
                                            Object... values)
        Throw IllegalArgumentException if value is strictly less than minimum or strictly greater than maximum.
        Parameters:
        minimum - the minimum, inclusive
        maximum - the maximum, inclusive
        value - the value to check
        reason - the exception message
        values - values to be put in placeholders in reason (e.g. “%s”).
        Returns:
        the value
        Throws:
        IllegalArgumentException - if the value is out of bounds
      • noNullElements

        public static <T> T[] noNullElements​(T[] array,
                                             String reason,
                                             Object... values)
        Throw IllegalArgumentException if one of the array elements is null.
        Type Parameters:
        T - array element type
        Parameters:
        array - array to check
        reason - exception message
        values - values to be put in placeholders in reason (e.g. “%s”).
        Returns:
        the array
        Throws:
        IllegalArgumentException - if one of the array elements is null
      • notEmpty

        public static <T> T[] notEmpty​(T[] array,
                                       String reason,
                                       Object... values)
        Throw IllegalArgumentException if the array is empty
        Type Parameters:
        T - array element type
        Parameters:
        array - array to check
        reason - exception message
        values - values to be put in placeholders in reason (e.g. “%s”).
        Returns:
        the array
        Throws:
        IllegalArgumentException - if the array is empty