Class ValueEnforcer


  • @Immutable
    public final class ValueEnforcer
    extends Object
    This class contains "runtime assertions" utility methods. It works like Objects.requireNonNull(Object) but offers many more possibilities.
    Author:
    Philip Helger
    • Method Detail

      • isEnabled

        public static boolean isEnabled()
        Returns:
        true if the assertions are enabled, false otherwise. By default the checks are enabled.
      • setEnabled

        public static void setEnabled​(boolean bEnabled)
        Enable or disable the checks. By default checks are enabled.
        Parameters:
        bEnabled - true to enable it, false otherwise.
      • isTrue

        public static void isTrue​(boolean bValue,
                                  String sMsg)
        Check that the passed value is true.
        Parameters:
        bValue - The value to check.
        sMsg - The message to be emitted in case the value is false
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isTrue

        public static void isTrue​(boolean bValue,
                                  @Nonnull
                                  Supplier<? extends String> aMsg)
        Check that the passed value is true.
        Parameters:
        bValue - The value to check.
        aMsg - The message to be emitted in case the value is false
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isTrue

        public static void isTrue​(@Nonnull
                                  BooleanSupplier aValue,
                                  String sMsg)
        Check that the passed value is true.
        Parameters:
        aValue - The value to check.
        sMsg - The message to be emitted in case the value is false
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isFalse

        public static void isFalse​(boolean bValue,
                                   String sMsg)
        Check that the passed value is false.
        Parameters:
        bValue - The value to check.
        sMsg - The message to be emitted in case the value is true
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isFalse

        public static void isFalse​(boolean bValue,
                                   @Nonnull
                                   Supplier<? extends String> aMsg)
        Check that the passed value is false.
        Parameters:
        bValue - The value to check.
        aMsg - The message to be emitted in case the value is true
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isFalse

        public static void isFalse​(@Nonnull
                                   BooleanSupplier aValue,
                                   String sMsg)
        Check that the passed value is false.
        Parameters:
        aValue - The value to check.
        sMsg - The message to be emitted in case the value is true
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isInstanceOf

        public static <T> void isInstanceOf​(@Nullable
                                            T aValue,
                                            @Nonnull
                                            Class<? extends T> aClass,
                                            String sMsg)
        Check that the passed value is an instance of the passed class.
        Type Parameters:
        T - Type to check.
        Parameters:
        aValue - The value to check. May be null.
        aClass - The class of which the passed value must be an instance. May not be null.
        sMsg - The message to be emitted in case the value is false
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isInstanceOf

        public static <T> void isInstanceOf​(@Nullable
                                            T aValue,
                                            @Nonnull
                                            Class<? extends T> aClass,
                                            @Nonnull
                                            Supplier<? extends String> aMsg)
        Check that the passed value is an instance of the passed class.
        Type Parameters:
        T - Type to check.
        Parameters:
        aValue - The value to check. May be null.
        aClass - The class of which the passed value must be an instance. May not be null.
        aMsg - The message to be emitted in case the value is false
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • notNull

        public static <T> T notNull​(T aValue,
                                    String sName)
        Check that the passed value is not null.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The value to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        NullPointerException - if the passed value is null.
      • notNull

        public static <T> T notNull​(T aValue,
                                    @Nonnull
                                    Supplier<? extends String> aName)
        Check that the passed value is not null.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The value to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        NullPointerException - if the passed value is null.
      • isNull

        public static void isNull​(Object aValue,
                                  String sName)
        Check that the passed value is null.
        Parameters:
        aValue - The value to check.
        sName - The name of the value (e.g. the parameter name)
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isNull

        public static void isNull​(Object aValue,
                                  @Nonnull
                                  Supplier<? extends String> aName)
        Check that the passed value is null.
        Parameters:
        aValue - The value to check.
        aName - The name of the value (e.g. the parameter name)
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • notEmpty

        public static <T extends CharSequence> T notEmpty​(T aValue,
                                                          String sName)
        Check that the passed String is neither null nor empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The String to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static <T extends CharSequence> T notEmpty​(T aValue,
                                                          @Nonnull
                                                          Supplier<? extends String> aName)
        Check that the passed String is neither null nor empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The String to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static <T> T[] notEmpty​(T[] aValue,
                                       String sName)
        Check that the passed Array is neither null nor empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The Array to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static <T> T[] notEmpty​(T[] aValue,
                                       @Nonnull
                                       Supplier<? extends String> aName)
        Check that the passed Array is neither null nor empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The Array to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static boolean[] notEmpty​(boolean[] aValue,
                                         String sName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static boolean[] notEmpty​(boolean[] aValue,
                                         @Nonnull
                                         Supplier<? extends String> aName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static byte[] notEmpty​(byte[] aValue,
                                      String sName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static byte[] notEmpty​(byte[] aValue,
                                      @Nonnull
                                      Supplier<? extends String> aName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static char[] notEmpty​(char[] aValue,
                                      String sName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static char[] notEmpty​(char[] aValue,
                                      @Nonnull
                                      Supplier<? extends String> aName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static double[] notEmpty​(double[] aValue,
                                        String sName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static double[] notEmpty​(double[] aValue,
                                        @Nonnull
                                        Supplier<? extends String> aName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static float[] notEmpty​(float[] aValue,
                                       String sName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static float[] notEmpty​(float[] aValue,
                                       @Nonnull
                                       Supplier<? extends String> aName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static int[] notEmpty​(int[] aValue,
                                     String sName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static int[] notEmpty​(int[] aValue,
                                     @Nonnull
                                     Supplier<? extends String> aName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static long[] notEmpty​(long[] aValue,
                                      String sName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static long[] notEmpty​(long[] aValue,
                                      @Nonnull
                                      Supplier<? extends String> aName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static short[] notEmpty​(short[] aValue,
                                       String sName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        public static short[] notEmpty​(short[] aValue,
                                       @Nonnull
                                       Supplier<? extends String> aName)
        Check that the passed Array is neither null nor empty.
        Parameters:
        aValue - The Array to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        @CodingStyleguideUnaware
        public static <T extends Collection<?>> T notEmpty​(T aValue,
                                                           String sName)
        Check that the passed Collection is neither null nor empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The String to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        @CodingStyleguideUnaware
        public static <T extends Iterable<?>> T notEmpty​(T aValue,
                                                         String sName)
        Check that the passed Iterable is neither null nor empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The String to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        @CodingStyleguideUnaware
        public static <T extends Iterable<?>> T notEmpty​(T aValue,
                                                         @Nonnull
                                                         Supplier<? extends String> aName)
        Check that the passed Iterable is neither null nor empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The String to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        @CodingStyleguideUnaware
        public static <T extends Map<?,​?>> T notEmpty​(T aValue,
                                                            String sName)
        Check that the passed Collection is neither null nor empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The String to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • notEmpty

        @CodingStyleguideUnaware
        public static <T extends Map<?,​?>> T notEmpty​(T aValue,
                                                            @Nonnull
                                                            Supplier<? extends String> aName)
        Check that the passed Collection is neither null nor empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The String to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty
      • noNullValue

        @Nullable
        public static <T> T[] noNullValue​(T[] aValue,
                                          String sName)
        Check that the passed Array contains no null value. But the whole array can be null or empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The Array to check. May be null.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value. Maybe null.
        Throws:
        IllegalArgumentException - if the passed value is not empty and a null value is contained
      • noNullValue

        @Nullable
        public static <T> T[] noNullValue​(T[] aValue,
                                          @Nonnull
                                          Supplier<? extends String> aName)
        Check that the passed Array contains no null value. But the whole array can be null or empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The Array to check. May be null.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value. Maybe null.
        Throws:
        IllegalArgumentException - if the passed value is not empty and a null value is contained
      • noNullValue

        @Nullable
        public static <T extends Iterable<?>> T noNullValue​(T aValue,
                                                            String sName)
        Check that the passed iterable contains no null value. But the whole iterable can be null or empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The collection to check. May be null.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value. Maybe null.
        Throws:
        IllegalArgumentException - if the passed value is not empty and a null value is contained
      • noNullValue

        @Nullable
        public static <T extends Iterable<?>> T noNullValue​(T aValue,
                                                            @Nonnull
                                                            Supplier<? extends String> aName)
        Check that the passed iterable contains no null value. But the whole iterable can be null or empty.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The collection to check. May be null.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value. Maybe null.
        Throws:
        IllegalArgumentException - if the passed value is not empty and a null value is contained
      • noNullValue

        @Nullable
        @CodingStyleguideUnaware
        public static <T extends Map<?,​?>> T noNullValue​(T aValue,
                                                               String sName)
        Check that the passed map is neither null nor empty and that no null key or value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The map to check. May be null.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value. Maybe null.
        Throws:
        IllegalArgumentException - if the passed value is not empty and a null key or null value is contained
      • noNullValue

        @Nullable
        @CodingStyleguideUnaware
        public static <T extends Map<?,​?>> T noNullValue​(T aValue,
                                                               @Nonnull
                                                               Supplier<? extends String> aName)
        Check that the passed map is neither null nor empty and that no null key or value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The map to check. May be null.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value. Maybe null.
        Throws:
        IllegalArgumentException - if the passed value is not empty and a null key or null value is contained
      • notNullNoNullValue

        public static <T> T[] notNullNoNullValue​(T[] aValue,
                                                 String sName)
        Check that the passed Array is not null and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The Array to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is null or a null value is contained
      • notNullNoNullValue

        public static <T> T[] notNullNoNullValue​(T[] aValue,
                                                 @Nonnull
                                                 Supplier<? extends String> aName)
        Check that the passed Array is not null and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The Array to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is null or a null value is contained
      • notNullNoNullValue

        public static <T extends Iterable<?>> T notNullNoNullValue​(T aValue,
                                                                   String sName)
        Check that the passed collection is not null and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The collection to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is null or a null value is contained
      • notNullNoNullValue

        public static <T extends Iterable<?>> T notNullNoNullValue​(T aValue,
                                                                   @Nonnull
                                                                   Supplier<? extends String> aName)
        Check that the passed collection is not null and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The collection to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is null or a null value is contained
      • notNullNoNullValue

        @CodingStyleguideUnaware
        public static <T extends Map<?,​?>> T notNullNoNullValue​(T aValue,
                                                                      String sName)
        Check that the passed map is not null and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The map to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is null or a null value is contained
      • notNullNoNullValue

        @CodingStyleguideUnaware
        public static <T extends Map<?,​?>> T notNullNoNullValue​(T aValue,
                                                                      @Nonnull
                                                                      Supplier<? extends String> aName)
        Check that the passed map is not null and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The map to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is null or a null value is contained
      • notEmptyNoNullValue

        public static <T> T[] notEmptyNoNullValue​(T[] aValue,
                                                  String sName)
        Check that the passed Array is neither null nor empty and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The Array to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty or a null value is contained
      • notEmptyNoNullValue

        public static <T> T[] notEmptyNoNullValue​(T[] aValue,
                                                  @Nonnull
                                                  Supplier<? extends String> aName)
        Check that the passed Array is neither null nor empty and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The Array to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty or a null value is contained
      • notEmptyNoNullValue

        public static <T extends Iterable<?>> T notEmptyNoNullValue​(T aValue,
                                                                    String sName)
        Check that the passed collection is neither null nor empty and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The collection to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty or a null value is contained
      • notEmptyNoNullValue

        public static <T extends Iterable<?>> T notEmptyNoNullValue​(T aValue,
                                                                    @Nonnull
                                                                    Supplier<? extends String> aName)
        Check that the passed collection is neither null nor empty and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The collection to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty or a null value is contained
      • notEmptyNoNullValue

        @CodingStyleguideUnaware
        public static <T extends Map<?,​?>> T notEmptyNoNullValue​(T aValue,
                                                                       String sName)
        Check that the passed map is neither null nor empty and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The map to check.
        sName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty or a null value is contained
      • notEmptyNoNullValue

        @CodingStyleguideUnaware
        public static <T extends Map<?,​?>> T notEmptyNoNullValue​(T aValue,
                                                                       @Nonnull
                                                                       Supplier<? extends String> aName)
        Check that the passed map is neither null nor empty and that no null value is contained.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The map to check.
        aName - The name of the value (e.g. the parameter name)
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is empty or a null value is contained
      • notNullNotEquals

        public static <T> T notNullNotEquals​(T aValue,
                                             String sName,
                                             @Nonnull
                                             T aUnexpectedValue)
        Check that the passed value is not null and not equal to the provided value.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The value to check. May not be null.
        sName - The name of the value (e.g. the parameter name)
        aUnexpectedValue - The value that may not be equal to aValue. May not be null.
        Returns:
        The passed value.
      • notNullNotEquals

        public static <T> T notNullNotEquals​(T aValue,
                                             @Nonnull
                                             Supplier<? extends String> aName,
                                             @Nonnull
                                             T aUnexpectedValue)
        Check that the passed value is not null and not equal to the provided value.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The value to check. May not be null.
        aName - The name of the value (e.g. the parameter name)
        aUnexpectedValue - The value that may not be equal to aValue. May not be null.
        Returns:
        The passed value.
      • notNullAndEquals

        public static <T> T notNullAndEquals​(T aValue,
                                             String sName,
                                             @Nonnull
                                             T aExpectedValue)
        Check that the passed value is not null and equal to the provided expected value.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The value to check.
        sName - The name of the value (e.g. the parameter name)
        aExpectedValue - The expected value. May not be null.
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • notNullAndEquals

        public static <T> T notNullAndEquals​(T aValue,
                                             @Nonnull
                                             Supplier<? extends String> aName,
                                             @Nonnull
                                             T aExpectedValue)
        Check that the passed value is not null and equal to the provided expected value.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The value to check.
        aName - The name of the value (e.g. the parameter name)
        aExpectedValue - The expected value. May not be null.
        Returns:
        The passed value.
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isSame

        public static <T> T isSame​(T aValue,
                                   String sName,
                                   @Nullable
                                   T aExpectedValue)
        Check that the passed value is the same as the provided expected value using == to check comparison.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The value to check.
        sName - The name of the value (e.g. the parameter name)
        aExpectedValue - The expected value. May be null.
        Returns:
        The passed value and maybe null if the expected value is null.
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isSame

        public static <T> T isSame​(T aValue,
                                   @Nonnull
                                   Supplier<? extends String> aName,
                                   @Nullable
                                   T aExpectedValue)
        Check that the passed value is the same as the provided expected value using == to check comparison.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The value to check.
        aName - The name of the value (e.g. the parameter name)
        aExpectedValue - The expected value. May be null.
        Returns:
        The passed value and maybe null if the expected value is null.
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isEqual

        public static <T> T isEqual​(T aValue,
                                    @Nullable
                                    T aExpectedValue,
                                    String sName)
        Check that the passed value is the same as the provided expected value using equals to check comparison.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The value to check.
        sName - The name of the value (e.g. the parameter name)
        aExpectedValue - The expected value. May be null.
        Returns:
        The passed value and maybe null if the expected value is null.
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isEqual

        public static <T> T isEqual​(T aValue,
                                    @Nullable
                                    T aExpectedValue,
                                    @Nonnull
                                    Supplier<? extends String> aName)
        Check that the passed value is the same as the provided expected value using equals to check comparison.
        Type Parameters:
        T - Type to be checked and returned
        Parameters:
        aValue - The value to check.
        aName - The name of the value (e.g. the parameter name)
        aExpectedValue - The expected value. May be null.
        Returns:
        The passed value and maybe null if the expected value is null.
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isEqual

        public static void isEqual​(int nValue,
                                   int nExpectedValue,
                                   String sName)
        Check that the passed value is the same as the provided expected value using == to check comparison.
        Parameters:
        nValue - The First value.
        nExpectedValue - The expected value.
        sName - The name of the value (e.g. the parameter name)
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isEqual

        public static void isEqual​(int nValue,
                                   int nExpectedValue,
                                   @Nonnull
                                   Supplier<? extends String> aName)
        Check that the passed value is the same as the provided expected value using == to check comparison.
        Parameters:
        nValue - The First value.
        nExpectedValue - The expected value.
        aName - The name of the value (e.g. the parameter name)
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isEqual

        public static void isEqual​(long nValue,
                                   long nExpectedValue,
                                   String sName)
        Check that the passed value is the same as the provided expected value using == to check comparison.
        Parameters:
        nValue - The First value.
        nExpectedValue - The expected value.
        sName - The name of the value (e.g. the parameter name)
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isEqual

        public static void isEqual​(long nValue,
                                   long nExpectedValue,
                                   @Nonnull
                                   Supplier<? extends String> aName)
        Check that the passed value is the same as the provided expected value using == to check comparison.
        Parameters:
        nValue - The First value.
        nExpectedValue - The expected value.
        aName - The name of the value (e.g. the parameter name)
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isEqual

        public static void isEqual​(double dValue,
                                   double dExpectedValue,
                                   String sName)
        Check that the passed value is the same as the provided expected value using == to check comparison.
        Parameters:
        dValue - The First value.
        dExpectedValue - The expected value.
        sName - The name of the value (e.g. the parameter name)
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isEqual

        public static void isEqual​(double dValue,
                                   double dExpectedValue,
                                   @Nonnull
                                   Supplier<? extends String> aName)
        Check that the passed value is the same as the provided expected value using == to check comparison.
        Parameters:
        dValue - The First value.
        dExpectedValue - The expected value.
        aName - The name of the value (e.g. the parameter name)
        Throws:
        IllegalArgumentException - if the passed value is not null.
      • isGE0

        public static int isGE0​(int nValue,
                                String sName)
      • isGE0

        public static long isGE0​(long nValue,
                                 String sName)
      • isGE0

        public static short isGE0​(short nValue,
                                  String sName)
      • isGE0

        public static double isGE0​(double dValue,
                                   String sName)
      • isGE0

        public static float isGE0​(float fValue,
                                  String sName)
      • isGT0

        public static int isGT0​(int nValue,
                                String sName)
      • isGT0

        public static long isGT0​(long nValue,
                                 String sName)
      • isGT0

        public static short isGT0​(short nValue,
                                  String sName)
      • isGT0

        public static double isGT0​(double dValue,
                                   String sName)
      • isGT0

        public static float isGT0​(float fValue,
                                  String sName)
      • isNE0

        public static int isNE0​(int nValue,
                                String sName)
      • isNE0

        public static long isNE0​(long nValue,
                                 String sName)
      • isNE0

        public static double isNE0​(double dValue,
                                   String sName)
      • isLE0

        public static int isLE0​(int nValue,
                                String sName)
      • isLE0

        public static long isLE0​(long nValue,
                                 String sName)
      • isLE0

        public static short isLE0​(short nValue,
                                  String sName)
      • isLE0

        public static double isLE0​(double dValue,
                                   String sName)
      • isLE0

        public static float isLE0​(float fValue,
                                  String sName)
      • isLT0

        public static int isLT0​(int nValue,
                                String sName)
      • isLT0

        public static long isLT0​(long nValue,
                                 String sName)
      • isLT0

        public static short isLT0​(short nValue,
                                  String sName)
      • isLT0

        public static double isLT0​(double dValue,
                                   String sName)
      • isLT0

        public static float isLT0​(float fValue,
                                  String sName)
      • isBetweenInclusive

        public static int isBetweenInclusive​(int nValue,
                                             String sName,
                                             int nLowerBoundInclusive,
                                             int nUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        nValue - Value
        sName - Name
        nLowerBoundInclusive - Lower bound
        nUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static int isBetweenInclusive​(int nValue,
                                             @Nonnull
                                             Supplier<? extends String> aName,
                                             int nLowerBoundInclusive,
                                             int nUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        nValue - Value
        aName - Name
        nLowerBoundInclusive - Lower bound
        nUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static long isBetweenInclusive​(long nValue,
                                              String sName,
                                              long nLowerBoundInclusive,
                                              long nUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        nValue - Value
        sName - Name
        nLowerBoundInclusive - Lower bound
        nUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static long isBetweenInclusive​(long nValue,
                                              @Nonnull
                                              Supplier<? extends String> aName,
                                              long nLowerBoundInclusive,
                                              long nUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        nValue - Value
        aName - Name
        nLowerBoundInclusive - Lower bound
        nUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static short isBetweenInclusive​(short nValue,
                                               String sName,
                                               short nLowerBoundInclusive,
                                               short nUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        nValue - Value
        sName - Name
        nLowerBoundInclusive - Lower bound
        nUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static short isBetweenInclusive​(short nValue,
                                               @Nonnull
                                               Supplier<? extends String> aName,
                                               short nLowerBoundInclusive,
                                               short nUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        nValue - Value
        aName - Name
        nLowerBoundInclusive - Lower bound
        nUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static double isBetweenInclusive​(double dValue,
                                                String sName,
                                                double dLowerBoundInclusive,
                                                double dUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        dValue - Value
        sName - Name
        dLowerBoundInclusive - Lower bound
        dUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static double isBetweenInclusive​(double dValue,
                                                @Nonnull
                                                Supplier<? extends String> aName,
                                                double dLowerBoundInclusive,
                                                double dUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        dValue - Value
        aName - Name
        dLowerBoundInclusive - Lower bound
        dUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static float isBetweenInclusive​(float fValue,
                                               String sName,
                                               float fLowerBoundInclusive,
                                               float fUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        fValue - Value
        sName - Name
        fLowerBoundInclusive - Lower bound
        fUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static float isBetweenInclusive​(float fValue,
                                               @Nonnull
                                               Supplier<? extends String> aName,
                                               float fLowerBoundInclusive,
                                               float fUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        fValue - Value
        aName - Name
        fLowerBoundInclusive - Lower bound
        fUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static BigDecimal isBetweenInclusive​(BigDecimal aValue,
                                                    String sName,
                                                    @Nonnull
                                                    BigDecimal aLowerBoundInclusive,
                                                    @Nonnull
                                                    BigDecimal aUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        aValue - Value
        sName - Name
        aLowerBoundInclusive - Lower bound
        aUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static BigDecimal isBetweenInclusive​(BigDecimal aValue,
                                                    @Nonnull
                                                    Supplier<? extends String> aName,
                                                    @Nonnull
                                                    BigDecimal aLowerBoundInclusive,
                                                    @Nonnull
                                                    BigDecimal aUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        aValue - Value
        aName - Name
        aLowerBoundInclusive - Lower bound
        aUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static BigInteger isBetweenInclusive​(BigInteger aValue,
                                                    String sName,
                                                    @Nonnull
                                                    BigInteger aLowerBoundInclusive,
                                                    @Nonnull
                                                    BigInteger aUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        aValue - Value
        sName - Name
        aLowerBoundInclusive - Lower bound
        aUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenInclusive

        public static BigInteger isBetweenInclusive​(BigInteger aValue,
                                                    @Nonnull
                                                    Supplier<? extends String> aName,
                                                    @Nonnull
                                                    BigInteger aLowerBoundInclusive,
                                                    @Nonnull
                                                    BigInteger aUpperBoundInclusive)
        Check if nValue ≥ nLowerBoundInclusive && nValue ≤ nUpperBoundInclusive
        Parameters:
        aValue - Value
        aName - Name
        aLowerBoundInclusive - Lower bound
        aUpperBoundInclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static int isBetweenExclusive​(int nValue,
                                             String sName,
                                             int nLowerBoundExclusive,
                                             int nUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        nValue - Value
        sName - Name
        nLowerBoundExclusive - Lower bound
        nUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static int isBetweenExclusive​(int nValue,
                                             @Nonnull
                                             Supplier<? extends String> aName,
                                             int nLowerBoundExclusive,
                                             int nUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        nValue - Value
        aName - Name
        nLowerBoundExclusive - Lower bound
        nUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static long isBetweenExclusive​(long nValue,
                                              String sName,
                                              long nLowerBoundExclusive,
                                              long nUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        nValue - Value
        sName - Name
        nLowerBoundExclusive - Lower bound
        nUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static long isBetweenExclusive​(long nValue,
                                              @Nonnull
                                              Supplier<? extends String> aName,
                                              long nLowerBoundExclusive,
                                              long nUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        nValue - Value
        aName - Name
        nLowerBoundExclusive - Lower bound
        nUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static short isBetweenExclusive​(short nValue,
                                               String sName,
                                               short nLowerBoundExclusive,
                                               short nUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        nValue - Value
        sName - Name
        nLowerBoundExclusive - Lower bound
        nUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static short isBetweenExclusive​(short nValue,
                                               @Nonnull
                                               Supplier<? extends String> aName,
                                               short nLowerBoundExclusive,
                                               short nUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        nValue - Value
        aName - Name
        nLowerBoundExclusive - Lower bound
        nUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static double isBetweenExclusive​(double dValue,
                                                String sName,
                                                double dLowerBoundExclusive,
                                                double dUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        dValue - Value
        sName - Name
        dLowerBoundExclusive - Lower bound
        dUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static double isBetweenExclusive​(double dValue,
                                                @Nonnull
                                                Supplier<? extends String> aName,
                                                double dLowerBoundExclusive,
                                                double dUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        dValue - Value
        aName - Name
        dLowerBoundExclusive - Lower bound
        dUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static float isBetweenExclusive​(float fValue,
                                               String sName,
                                               float fLowerBoundExclusive,
                                               float fUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        fValue - Value
        sName - Name
        fLowerBoundExclusive - Lower bound
        fUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static float isBetweenExclusive​(float fValue,
                                               @Nonnull
                                               Supplier<? extends String> aName,
                                               float fLowerBoundExclusive,
                                               float fUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        fValue - Value
        aName - Name
        fLowerBoundExclusive - Lower bound
        fUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static BigDecimal isBetweenExclusive​(BigDecimal aValue,
                                                    String sName,
                                                    @Nonnull
                                                    BigDecimal aLowerBoundExclusive,
                                                    @Nonnull
                                                    BigDecimal aUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        aValue - Value
        sName - Name
        aLowerBoundExclusive - Lower bound
        aUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static BigDecimal isBetweenExclusive​(BigDecimal aValue,
                                                    @Nonnull
                                                    Supplier<? extends String> aName,
                                                    @Nonnull
                                                    BigDecimal aLowerBoundExclusive,
                                                    @Nonnull
                                                    BigDecimal aUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        aValue - Value
        aName - Name
        aLowerBoundExclusive - Lower bound
        aUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static BigInteger isBetweenExclusive​(BigInteger aValue,
                                                    String sName,
                                                    @Nonnull
                                                    BigInteger aLowerBoundExclusive,
                                                    @Nonnull
                                                    BigInteger aUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        aValue - Value
        sName - Name
        aLowerBoundExclusive - Lower bound
        aUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isBetweenExclusive

        public static BigInteger isBetweenExclusive​(BigInteger aValue,
                                                    @Nonnull
                                                    Supplier<? extends String> aName,
                                                    @Nonnull
                                                    BigInteger aLowerBoundExclusive,
                                                    @Nonnull
                                                    BigInteger aUpperBoundExclusive)
        Check if nValue > nLowerBoundInclusive && nValue < nUpperBoundInclusive
        Parameters:
        aValue - Value
        aName - Name
        aLowerBoundExclusive - Lower bound
        aUpperBoundExclusive - Upper bound
        Returns:
        The value
      • isArrayOfsLen

        public static void isArrayOfsLen​(boolean[] aArray,
                                         @Nonnegative
                                         int nOfs,
                                         @Nonnegative
                                         int nLen)