ArgumentChecker { public static <T> T[] noNulls(T[] parameter, String name) { notNull(parameter, name); for (int i = 0; i < parameter.length; i++) { if (parameter[i] == null) { throw new IllegalArgumentException("Input parameter array '" + name + "' must not contain null at index " + i); } } return parameter; } private  ArgumentChecker(); static void isTrue(boolean validIfTrue, String message); static void isTrue(boolean validIfTrue, String message, Object... arg); static void isFalse(boolean validIfFalse, String message); static void isFalse(boolean validIfFalse, String message, Object... arg); static T notNull(T parameter, String name); static T notNullInjected(T parameter, String name); static String notBlank(String parameter, String name); static String notEmpty(String parameter, String name); static T[] notEmpty(T[] parameter, String name); static int[] notEmpty(int[] parameter, String name); static long[] notEmpty(long[] parameter, String name); static double[] notEmpty(double[] parameter, String name); static I notEmpty(I parameter, String name); static C notEmpty(C parameter, String name); static M notEmpty(M parameter, String name); static T[] noNulls(T[] parameter, String name); static I noNulls(I parameter, String name); static M noNulls(M parameter, String name); static int notNegative(int parameter, String name); static long notNegative(long parameter, String name); static double notNegative(double parameter, String name); static int notNegativeOrZero(int parameter, String name); static long notNegativeOrZero(long parameter, String name); static double notNegativeOrZero(double parameter, String name); static double notNegativeOrZero(double parameter, double eps, String name); @Deprecated static double notNegativeOrZero(double parameter, double eps, String message, Object... args); static double notZero(double parameter, double eps, String name); static boolean hasNullElement(Iterable<?> iterable); static boolean hasNegativeElement(Iterable<Double> iterable); static boolean isInRangeExclusive(double low, double high, double value); static boolean isInRangeInclusive(double low, double high, double value); static boolean isInRangeExcludingLow(double low, double high, double value); static boolean isInRangeExcludingHigh(double low, double high, double value); static void inOrderOrEqual(Comparable<? super T> obj1, T obj2, String param1, String param2);  }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_noNulls_Array_null() { Object[] array = null; try { ArgumentChecker.noNulls(array, "name"); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage().contains("'name'"), true); throw ex; } }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_noNulls_Array_nullElement() { Object[] array = new Object[] {null}; try { ArgumentChecker.noNulls(array, "name"); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage().contains("'name'"), true); throw ex; } }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_noNulls_Iterable_null() { Iterable<?> coll = null; try { ArgumentChecker.noNulls(coll, "name"); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage().contains("'name'"), true); throw ex; } }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_noNulls_Iterable_nullElement() { Iterable<?> coll = Arrays.asList((Object) null); try { ArgumentChecker.noNulls(coll, "name"); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage().contains("'name'"), true); throw ex; } }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_noNulls_Map_null() { Map<Object, Object> map = null; try { ArgumentChecker.noNulls(map, "name"); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage().contains("'name'"), true); throw ex; } }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_noNulls_Map_nullKey() { Map<Object, Object> map = new HashMap<>(); map.put("A", "B"); map.put(null, "Z"); try { ArgumentChecker.noNulls(map, "name"); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage().contains("'name'"), true); throw ex; } }
@Test(expectedExceptions = IllegalArgumentException.class) public void test_noNulls_Map_nullValue() { Map<Object, Object> map = new HashMap<>(); map.put("A", "B"); map.put("Z", null); try { ArgumentChecker.noNulls(map, "name"); } catch (IllegalArgumentException ex) { assertEquals(ex.getMessage().contains("'name'"), true); throw ex; } }