Returns the next element in iterator or defaultValue if the iterator is empty. The Iterables analog to this method is Iterables#getFirst. @param defaultValue the default value to return if the iterator is empty @return the next element of iterator or the def
(Iterator<? extends T> iterator, @Nullable T defaultValue)
| 863 | */ |
| 864 | |
| 865 | @Nullable |
| 866 | public static <T> T getNext(Iterator<? extends T> iterator, @Nullable T defaultValue) { |
| 867 | return iterator.hasNext() ? iterator.next() : defaultValue; |
| 868 | } |
| 869 | |
| 870 | /** |
| 871 | * Advances {@code iterator} to the end, returning the last element. |
no test coverage detected