EmptyIterable implements Iterable<T> { @Override public Iterator<T> iterator() { return Collections.emptyIterator(); }  @Override Iterator<T> iterator();  }
@Test public void test() { EmptyIterable<Byte> iterable = new EmptyIterable<>(); Iterator<Byte> iterator = iterable.iterator(); assertNotNull(iterator); assertFalse(iterator.hasNext()); try { assertNull(iterator.next()); fail("NoSuchElementException was exptect."); } catch (NoSuchElementException e) { } }