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

org.zalando.riptide.capture.Capture Maven / Gradle / Ivy

package org.zalando.riptide.capture;

import org.apiguardian.api.API;
import org.springframework.http.client.ClientHttpResponse;
import org.zalando.fauxpas.ThrowingConsumer;

import javax.annotation.Nullable;
import java.util.function.Function;

import static org.apiguardian.api.API.Status.STABLE;

@API(status = STABLE)
public interface Capture extends ThrowingConsumer, Function {

    void capture(@Nullable T result) throws IllegalStateException;

    T retrieve() throws CaptureException;

    @Override
    default void tryAccept(@Nullable final T result) {
        capture(result);
    }

    @Override
    default T apply(final ClientHttpResponse response) {
        return retrieve();
    }

    static  Capture empty() {
        return new DefaultCapture<>();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy