Class Require


  • public class Require
    extends Object
    Author:
    Kilian
    • Constructor Summary

      Constructors 
      Constructor Description
      Require()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T[] allNull​(T[] array)
      Checks if the supplied array does only contain null values and throws a IllegalArgumentException if it does not..
      static <T> T[] allNull​(T[] array, String message)
      Checks if the supplied array does only contain null values and throws a IllegalArgumentException if it does not..
      static <T> T[] deepNonNull​(T[] array)
      Deeply checks if the supplied array does not contain null values and throws a IllegalArgumentException if it does.
      static <T> T[] deepNonNull​(T[] array, String message)
      Deeply checks if the supplied array does not contain null values and throws a IllegalArgumentException if it does.
      static <T extends Number>
      T
      evenValue​(T value)
      Checks if the supplied argument is an even non null numeric value and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      T
      evenValue​(T value, String message)
      Checks if the supplied argument is an even non null numeric value and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      T
      exact​(T valueToCheck, T target)
      Checks if the supplied argument is the exact numeric value as the supplied argument and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      T
      exact​(T valueToCheck, T target, String message)
      Checks if the supplied argument is the exact numeric value as the supplied argument and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      T
      greaterThan​(T value, T lowerBound)
      Checks if the supplied argument is strictly greater than the lower bound value and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      T
      greaterThan​(T value, T lowerBound, String message)
      Checks if the supplied argument is strictly greater than the lower bound value and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      Collection<T>
      inRange​(Collection<T> value, T lowerBound, T higherBound, String message)
      Checks if the supplied argument is lays within the given bounds throws a IllegalArgumentException if it doesn't
      static <T extends Number>
      T
      inRange​(T value, T lowerBound, T higherBound)
      Checks if the supplied argument is lays within the given bounds throws a IllegalArgumentException if it doesn't
      static <T extends Number>
      T
      inRange​(T value, T lowerBound, T higherBound, String message)
      Checks if the supplied argument is lays within the given bounds throws a IllegalArgumentException if it doesn't
      static <T extends Number>
      T
      lessThan​(T value, T upperBound)
      Checks if the supplied argument is strictly less than the upper bound value and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      T
      lessThan​(T value, T upperBound, String message)
      Checks if the supplied argument is strictly less than the upper bound value and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      T
      negativeValue​(T value)
      Checks if the supplied argument is a negative non null numeric value and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      T
      negativeValue​(T value, String message)
      Checks if the supplied argument is a negative non null numeric value and throws a IllegalArgumentException if it isn't
      static <T> Collection<T> nonNull​(Collection<T> list)
      Checks if the supplied Collection does not contain null values and throws a IllegalArgumentException if it does.
      static <T> Collection<T> nonNull​(Collection<T> list, String message)
      Checks if the supplied Collection does not contain null values and throws a IllegalArgumentException if it does.
      static <T> T[] nonNull​(T[] array)
      Checks if the supplied array does not contain null values and throws a IllegalArgumentException if it does.
      static <T> T[] nonNull​(T[] array, String message)
      Checks if the supplied array does not contain null values and throws a IllegalArgumentException if it does.
      static <T extends Number>
      T
      oddValue​(T value)
      Checks if the supplied argument is an odd non null numeric value and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      T
      oddValue​(T value, String message)
      Checks if the supplied argument is an odd non null numeric value and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      T
      positiveValue​(T value)
      Checks if the supplied argument is a positive non null numeric value and throws a IllegalArgumentException if it isn't
      static <T extends Number>
      T
      positiveValue​(T value, String message)
      Checks if the supplied argument is a positive non null numeric value and throws a IllegalArgumentException if it isn't
    • Constructor Detail

      • Require

        public Require()
    • Method Detail

      • exact

        public static <T extends Number> T exact​(T valueToCheck,
                                                 T target)
        Checks if the supplied argument is the exact numeric value as the supplied argument and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        valueToCheck - to be checked
        target - the value to check against
        Returns:
        The supplied value
        Since:
        1.5.8 com.github.kilianB
      • exact

        public static <T extends Number> T exact​(T valueToCheck,
                                                 T target,
                                                 String message)
        Checks if the supplied argument is the exact numeric value as the supplied argument and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        valueToCheck - to be checked
        target - the value to check against
        message - to be thrown in case of error
        Returns:
        The supplied value
        Since:
        1.5.8 com.github.kilianB
      • positiveValue

        public static <T extends Number> T positiveValue​(T value)
        Checks if the supplied argument is a positive non null numeric value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • positiveValue

        public static <T extends Number> T positiveValue​(T value,
                                                         String message)
        Checks if the supplied argument is a positive non null numeric value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        message - to be thrown in case of error
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • inRange

        public static <T extends Number> T inRange​(T value,
                                                   T lowerBound,
                                                   T higherBound,
                                                   String message)
        Checks if the supplied argument is lays within the given bounds throws a IllegalArgumentException if it doesn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        lowerBound - inclusively
        higherBound - inclusively
        message - to be thrown in case of error
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • inRange

        public static <T extends NumberCollection<T> inRange​(Collection<T> value,
                                                               T lowerBound,
                                                               T higherBound,
                                                               String message)
        Checks if the supplied argument is lays within the given bounds throws a IllegalArgumentException if it doesn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        lowerBound - inclusively
        higherBound - inclusively
        message - to be thrown in case of error
        Returns:
        The supplied value
        Since:
        1.1.0 com.github.kilianB
      • inRange

        public static <T extends Number> T inRange​(T value,
                                                   T lowerBound,
                                                   T higherBound)
        Checks if the supplied argument is lays within the given bounds throws a IllegalArgumentException if it doesn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        lowerBound - inclusively
        higherBound - inclusively
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • nonNull

        public static <T> T[] nonNull​(T[] array)
        Checks if the supplied array does not contain null values and throws a IllegalArgumentException if it does.
        Type Parameters:
        T - the type of the value
        Parameters:
        array - to be checked
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • nonNull

        public static <T> T[] nonNull​(T[] array,
                                      String message)
        Checks if the supplied array does not contain null values and throws a IllegalArgumentException if it does.
        Type Parameters:
        T - the type of the value
        Parameters:
        array - to be checked
        message - message to be thrown in case of failure
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • deepNonNull

        public static <T> T[] deepNonNull​(T[] array)
        Deeply checks if the supplied array does not contain null values and throws a IllegalArgumentException if it does.

        This method supports nested arrays.

        Type Parameters:
        T - the type of the value
        Parameters:
        array - to be checked
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • deepNonNull

        public static <T> T[] deepNonNull​(T[] array,
                                          String message)
        Deeply checks if the supplied array does not contain null values and throws a IllegalArgumentException if it does.

        This method supports nested arrays.

        Type Parameters:
        T - the type of the value
        Parameters:
        array - to be checked
        message - message to be thrown in case of failure
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • allNull

        public static <T> T[] allNull​(T[] array)
        Checks if the supplied array does only contain null values and throws a IllegalArgumentException if it does not..
        Type Parameters:
        T - the type of the value
        Parameters:
        array - to be checked
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • allNull

        public static <T> T[] allNull​(T[] array,
                                      String message)
        Checks if the supplied array does only contain null values and throws a IllegalArgumentException if it does not..
        Type Parameters:
        T - the type of the value
        Parameters:
        array - to be checked
        message - message to be thrown in case of failure
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • nonNull

        public static <T> Collection<T> nonNull​(Collection<T> list)
        Checks if the supplied Collection does not contain null values and throws a IllegalArgumentException if it does.
        Type Parameters:
        T - the type of the value
        Parameters:
        list - to be checked
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • nonNull

        public static <T> Collection<T> nonNull​(Collection<T> list,
                                                String message)
        Checks if the supplied Collection does not contain null values and throws a IllegalArgumentException if it does.
        Type Parameters:
        T - the type of the value
        Parameters:
        list - to be checked
        message - message to be thrown in case of failure
        Returns:
        The supplied value
        Since:
        1.0.0 com.github.kilianB
      • oddValue

        public static <T extends Number> T oddValue​(T value)
        Checks if the supplied argument is an odd non null numeric value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        Returns:
        The supplied value
        Since:
        1.5.2 com.github.kilianB
      • oddValue

        public static <T extends Number> T oddValue​(T value,
                                                    String message)
        Checks if the supplied argument is an odd non null numeric value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        message - to be thrown in case of error
        Returns:
        The supplied value
        Since:
        1.5.2 com.github.kilianB
      • evenValue

        public static <T extends Number> T evenValue​(T value)
        Checks if the supplied argument is an even non null numeric value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        Returns:
        The supplied value
        Since:
        1.5.2 com.github.kilianB
      • evenValue

        public static <T extends Number> T evenValue​(T value,
                                                     String message)
        Checks if the supplied argument is an even non null numeric value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        message - to be thrown in case of error
        Returns:
        The supplied value
        Since:
        1.5.2 com.github.kilianB
      • negativeValue

        public static <T extends Number> T negativeValue​(T value)
        Checks if the supplied argument is a negative non null numeric value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        Returns:
        The supplied value
        Since:
        1.5.2 com.github.kilianB
      • negativeValue

        public static <T extends Number> T negativeValue​(T value,
                                                         String message)
        Checks if the supplied argument is a negative non null numeric value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        message - to be thrown in case of error
        Returns:
        The supplied value
        Since:
        1.5.2 com.github.kilianB
      • lessThan

        public static <T extends Number> T lessThan​(T value,
                                                    T upperBound)
        Checks if the supplied argument is strictly less than the upper bound value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        upperBound - the higher bound to check against
        Returns:
        The supplied value
        Since:
        1.5.2 com.github.kilianB
      • lessThan

        public static <T extends Number> T lessThan​(T value,
                                                    T upperBound,
                                                    String message)
        Checks if the supplied argument is strictly less than the upper bound value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        upperBound - the higher bound to check against
        message - to be thrown in case of error
        Returns:
        The supplied value
        Since:
        1.5.2 com.github.kilianB
      • greaterThan

        public static <T extends Number> T greaterThan​(T value,
                                                       T lowerBound)
        Checks if the supplied argument is strictly greater than the lower bound value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        lowerBound - the lower bound to check against
        Returns:
        The supplied value
        Since:
        1.5.2 com.github.kilianB
      • greaterThan

        public static <T extends Number> T greaterThan​(T value,
                                                       T lowerBound,
                                                       String message)
        Checks if the supplied argument is strictly greater than the lower bound value and throws a IllegalArgumentException if it isn't
        Type Parameters:
        T - the type of the value
        Parameters:
        value - to be checked
        lowerBound - the lower bound to check against
        message - to be thrown in case of error
        Returns:
        The supplied value
        Since:
        1.5.2 com.github.kilianB