1 /* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 6 package org.mockito.internal.util; 7 8 /** 9 * Pre-made preconditions 10 */ 11 public class Checks { 12 checkNotNull(T value, String checkedValue)13 public static <T> T checkNotNull(T value, String checkedValue) { 14 if(value == null) { 15 throw new IllegalArgumentException(checkedValue + " should not be null"); 16 } 17 return value; 18 } 19 checkItemsNotNull(T iterable, String checkedIterable)20 public static <T extends Iterable<?>> T checkItemsNotNull(T iterable, String checkedIterable) { 21 checkNotNull(iterable, checkedIterable); 22 for (Object item : iterable) { 23 checkNotNull(item, "item in " + checkedIterable); 24 } 25 return iterable; 26 } 27 } 28