@ParametersAreNonnullByDefault public final class MoreIterators extends Object
Iterator instances.| Modifier and Type | Method and Description |
|---|---|
static <E> Optional<E> |
firstElement(Iterator<E> iterator)
Returns the first element contained in
iterator. |
static boolean |
isEmpty(Iterator<?> iterator)
Determines if the given
iterator contains no element. |
static boolean |
notEmpty(Iterator<?> iterator)
Determines if the given
iterator contains at least one element. |
static <E> Optional<E> |
onlyElement(Iterator<E> iterator)
Returns the single element contained in
iterator. |
public static boolean isEmpty(Iterator<?> iterator)
iterator contains no element.iterator - the iteratortrue if the iterator contains no elementpublic static boolean notEmpty(Iterator<?> iterator)
iterator contains at least one element.iterator - the iteratortrue if the iterator contains at least one element@Nonnull public static <E> Optional<E> onlyElement(Iterator<E> iterator)
iterator.iterator - the iteratorOptional containing the single element of the iterator, or Optional.empty() if
the iterator is empty.IllegalArgumentException - if the iterator contains more than one element@Nonnull public static <E> Optional<E> firstElement(Iterator<E> iterator)
iterator.iterator - the iteratorOptional containing the first element of the iterator, or Optional.empty() if
the iterator is empty.Copyright © 2017–2019 Atlanmod. All rights reserved.