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

org.zalando.riptide.compatibility.ExtractRoute Maven / Gradle / Ivy

The newest version!
package org.zalando.riptide.compatibility;

import org.springframework.web.client.ResponseExtractor;
import org.zalando.riptide.Route;
import org.zalando.riptide.capture.Capture;

import javax.annotation.Nullable;

import static org.zalando.fauxpas.TryWith.tryWith;

final class ExtractRoute {

    private ExtractRoute() {

    }

    static  Route extractTo(@Nullable final ResponseExtractor extractor, final Capture capture) {
        return (response, reader) ->
                tryWith(response, ignored -> {
                    if (extractor == null) {
                        capture.capture(null);
                    } else {
                        capture.capture(extractor.extractData(response));
                    }
                });
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy