public Stream < T > merge ( final T value ) { return new Stream < T > ( ) { @ Override public Iterator < T > iterator ( ) { return new ReadOnlyIterator < T > ( ) { Iterator < T > iterator = Stream . this . iterator ( ) ; boolean completed ; @ Override public boolean hasNext ( ) { return iterator . hasNext ( ) || ! completed ; } @ Override public T next ( ) { if ( iterator . hasNext ( ) ) return iterator . next ( ) ; completed = true ; return value ; } } ; } } ; }
Returns a new stream that contains all items of the current stream with addition of a given item .