All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zalando.riptide.micrometer.CompletableFutures Maven / Gradle / Ivy

There is a newer version: 4.1.0
Show newest version
package org.zalando.riptide.micrometer;

import org.zalando.fauxpas.ThrowingBiConsumer;
import org.zalando.fauxpas.ThrowingConsumer;

import static java.util.Objects.nonNull;

final class CompletableFutures {

    private CompletableFutures() {
        // nothing to do
    }

    static  ThrowingBiConsumer onResult(
            final ThrowingConsumer consumer) {

        return (result, throwable) -> {
            if (nonNull(result)) {
                consumer.tryAccept(result);
            }
        };
    }

    static  ThrowingBiConsumer onError(
            final ThrowingConsumer consumer) {

        return (result, throwable) -> {
            if (nonNull(throwable)) {
                consumer.tryAccept(throwable);
            }
        };
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy