public static <E> Optional<E> maybeOne(E[] array) {
        return new MaybeOneElement<E>().apply(new ArrayIterator<>(array));
    }
public static < E > Optional < E > maybeOne ( E [ ] array ) { return new MaybeOneElement < E > ( ) . apply ( new ArrayIterator < > ( array ) ) ; }
Yields the only element if found, nothing otherwise.

@param <E> the array element type
@param array the array that will be consumed
@throws IllegalStateException if the iterator contains more than one
element
@return just the element or nothing