Map the result from a publisher using the given mapper.

@param publisher The publisher
@param consumer  The mapper
@param <T>       The generic type
@return The mapped publisher
160864
public static <T> Publisher<T> then(Publisher<T> publisher, Consumer<T> consumer) {
        return actual -> publisher.subscribe(new CompletionAwareSubscriber<T>() {
            @Override
            protected void doOnSubscribe(Subscription subscription) {
                actual.onSubscribe(subscription);
            }

            @Override
            protected void doOnNext(T message) {
                try {
                    actual.onNext(message);
                    consumer.accept(message);
                } catch (Throwable e) {
                    onError(e);
                }
            }

            @Override
            protected void doOnError(Throwable t) {
                actual.onError(t);
            }

            @Override
            protected void doOnComplete() {
                actual.onComplete();
            }
        });
    }
151652
public static <T> StreamConverter<T> streamConverter(final ObjectMapper mapper) {
        return streamConverter(mapper, Arrays.asList(
                APPLICATION_JSON_SEQ, APPLICATION_STREAM_JSON, APPLICATION_X_JSON_STREAM));
    }
405904
@Nonnull
	public static <R> LBiDblFunctionBuilder<R> biDblFunction(Consumer<LBiDblFunction<R>> consumer) {
		return new LBiDblFunctionBuilder(consumer);
	}
456162
public <R> ValueTransformer<W,R> mergeMap(Function<? super T, ? extends Publisher<? extends R>> mapper) {
        return unitAnyM(this.transformerStream().map(v->v.mergeMap(mapper)));
    }
373197
@Nonnull
	public static <T> LPredicateBuilder<T> predicate(Consumer<LPredicate<T>> consumer) {
		return new LPredicateBuilder(consumer);
	}
266111
@Nonnull
	public static <T> LObjCharPredicateBuilder<T> objCharPredicate(Consumer<LObjCharPredicate<T>> consumer) {
		return new LObjCharPredicateBuilder(consumer);
	}
1002029
@Nonnull
	public static <T> LTieFltFunctionBuilder<T> tieFltFunction(Consumer<LTieFltFunction<T>> consumer) {
		return new LTieFltFunctionBuilder(consumer);
	}
402978
@Nonnull
	public static <T> LObjIntPredicateBuilder<T> objIntPredicate(Consumer<LObjIntPredicate<T>> consumer) {
		return new LObjIntPredicateBuilder(consumer);
	}
284524
@Nonnull
	public static <T1, T2, R> LBiObjDblFunctionBuilder<T1, T2, R> biObjDblFunction(Consumer<LBiObjDblFunction<T1, T2, R>> consumer) {
		return new LBiObjDblFunctionBuilder(consumer);
	}
350395
@Nonnull
	public static <T1, T2> LToDblBiFunctionBuilder<T1, T2> toDblBiFunction(Consumer<LToDblBiFunction<T1, T2>> consumer) {
		return new LToDblBiFunctionBuilder(consumer);
	}
699841
@Nonnull
	public static <T> ToIntFunctionBuilder<T> toIntFunction(Consumer<ToIntFunction<T>> consumer) {
		return new ToIntFunctionBuilder(consumer);
	}
1081969
public static <T> T convertPublisher(Object object, Class<T> publisherType) {
        Objects.requireNonNull(object, "Invalid argument [object]: " + object);
        Objects.requireNonNull(object, "Invalid argument [publisherType]: " + publisherType);
        if (object instanceof CompletableFuture) {
            @SuppressWarnings("unchecked") Publisher<T> futurePublisher = (Publisher<T>) Publishers.fromCompletableFuture(() -> ((CompletableFuture) object));
            return ConversionService.SHARED.convert(futurePublisher, publisherType)
                    .orElseThrow(() -> new IllegalArgumentException("Unsupported Reactive type: " + object.getClass()));
        } else {
            return ConversionService.SHARED.convert(object, publisherType)
                    .orElseThrow(() -> new IllegalArgumentException("Unsupported Reactive type: " + object.getClass()));
        }
    }
439420
@Nonnull
	public static <T1, T2> LBiObjSrtPredicateBuilder<T1, T2> biObjSrtPredicate(Consumer<LBiObjSrtPredicate<T1, T2>> consumer) {
		return new LBiObjSrtPredicateBuilder(consumer);
	}
535073
@Nonnull
	public static <T> LObjBiIntPredicateBuilder<T> objBiIntPredicate(Consumer<LObjBiIntPredicate<T>> consumer) {
		return new LObjBiIntPredicateBuilder(consumer);
	}
955161
@Nonnull
	public static <T, R> LObjDblFunctionBuilder<T, R> objDblFunction(Consumer<LObjDblFunction<T, R>> consumer) {
		return new LObjDblFunctionBuilder(consumer);
	}
909119
public ListenableFuture<SegmentsAndMetadata> publishAll(final TransactionalSegmentPublisher publisher)
  {
    final Map<String, SegmentsForSequence> snapshot;
    synchronized (segments) {
      snapshot = ImmutableMap.copyOf(segments);
    }

    return publishInBackground(
        new SegmentsAndMetadata(
            snapshot
                .values()
                .stream()
                .flatMap(SegmentsForSequence::allSegmentStateStream)
                .map(segmentWithState -> Preconditions
                    .checkNotNull(
                        segmentWithState.getDataSegment(),
                        "dataSegment for segmentId[%s]",
                        segmentWithState.getSegmentIdentifier()
                    )
                )
                .collect(Collectors.toList()),
            null
        ),
        publisher
    );
  }
1065417
public <T> Stream<T> stream( Publisher<T> pub ) {
        return stream(pub, batchSize);
    }