guava/src/com/google/common/collect/Iterators.java
public static <T> UnmodifiableIterator<T> singletonIterator(final @Nullable T value) {
    return new UnmodifiableIterator<T>() {
      boolean done;

      @Override
      public boolean hasNext() {
        return !done;
      }

      @Override
      public T next() {
        if (done) {
          throw new NoSuchElementException();
        }
        done = true;
        return value;
      }
    };
  }
public static <T> UnmodifiableIterator<T> singletonIterator(final @Nullable T value) {
    return new UnmodifiableIterator<T>() {
      boolean done;

      @Override
      public boolean hasNext() {
        return !done;
      }

      @Override
      public T next() {
        if (done) {
          throw new NoSuchElementException();
        }
        done = true;
        return value;
      }
    };
  }
public static < T > UnmodifiableIterator < T > singletonIterator ( final @ Nullable T value ) { return new UnmodifiableIterator < T > ( ) { boolean done ; @ Override public boolean hasNext ( ) { return ! done ; } @ Override public T next ( ) { if ( done ) { throw new NoSuchElementException ( ) ; } done = true ; return value ; } } ; }
Returns an iterator containing only {@code value}.

<p>The {@link Iterable} equivalent of this method is {@link Collections#singleton}.
Returns an iterator containing only { @code value } .