Lists { public static boolean sizeIs(final List<?> list, final int size) { if (size == 0) { return list == null || list.isEmpty(); } else { return list != null && list.size() == size; } } private  Lists(); static List<T> createWhenNull(final List<T> list); static List<T> create(final T item); static T firstEntry(final List<T> list); static boolean isEmpty(final List<?> list); static boolean isNotEmpty(final List<?> list); static boolean sizeIs(final List<?> list, final int size); static List<T> emptyToNull(final List<T> list);  }
@Test public void testSizeIs() { final List<Integer> nullList = null; final List<Integer> listWithoutEntries = new ArrayList<Integer>(); final List<Integer> listWithOneEntry = Arrays.asList(1); assertThat(Lists.sizeIs(nullList, 0), is(true)); assertThat(Lists.sizeIs(listWithoutEntries, 0), is(true)); assertThat(Lists.sizeIs(listWithOneEntry, 1), is(true)); }