public static <E> Iterator<E> iterator(BooleanSupplier hasNext,
                                         Supplier<E> next) {
    Objects.requireNonNull(hasNext, "hasNext");
    Objects.requireNonNull(next, "next");

    class LambdaIterator extends BaseIterator<E> {
      @Override
      public boolean hasNext() {
        return hasNext.getAsBoolean();
      }

      @Override
      protected E nextElement() {
        return next.get();
      }
    }

    return new LambdaIterator();
  }
public static < E > Iterator < E > iterator ( BooleanSupplier hasNext , Supplier < E > next ) { Objects . requireNonNull ( hasNext , "hasNext" ) ; Objects . requireNonNull ( next , "next" ) ; class LambdaIterator extends BaseIterator < E > { @ Override public boolean hasNext ( ) { return hasNext . getAsBoolean ( ) ; } @ Override protected E nextElement ( ) { return next . get ( ) ; } } return new LambdaIterator ( ) ; }
Provides an {@link java.util.Iterator} backed by functional interfaces.
{@link java.util.Iterator#remove} is not supported.

@param hasNext used to implement {@link java.util.Iterator#hasNext()}
@param next used to implement {@link java.util.Iterator#next()}
@param <E> the generic type
@return a new instance