Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package de.otto.edison.hystrix.http;
 
 
import static com.netflix.hystrix.HystrixCommand.Setter.withGroupKey;
import static java.util.Objects.requireNonNull;
import static java.util.Optional.ofNullable;

A fluent builder used to create and configure http commands.

Author(s):
Guido Steinacker
Since:
16.04.15
public final class HttpCommandBuilder<T> {
    private Function<Response, T> responseMapper = null;
    protected HystrixCommand.Setter setter;
    protected Optional<Supplier<T>> optionalFallback = Optional.empty();
    protected int timeout = 10;
    protected TimeUnit timeUnit = .;
    public static HttpCommandBuilder<ResponsehttpCommand() {
        return new HttpCommandBuilder<Response>().mappedBy((r)->r);
    }
    public static <T> HttpCommandBuilder<T> httpCommand(final Class<T> type) {
        return new HttpCommandBuilder<T>();
    }
    public HttpCommandBuilder<T> inGroup(final HystrixCommandGroupKey group) {
        this. = withGroupKey(group);
        return this;
    }
    public HttpCommandBuilder<T> inGroup(final String hystrixCommandGgroup) {
        this. = withGroupKey(HystrixCommandGroupKey.Factory.asKey(hystrixCommandGgroup));
        return this;
    }
    public HttpCommandBuilder<T> configuredBy(final HystrixCommand.Setter setter) {
        this. = setter;
        return this;
    }
    public HttpCommandBuilder<T> forRequest(final AsyncHttpClient.BoundRequestBuilder requestBuilder) {
        this. = requireNonNull(requestBuilder);
        return this;
    }
    public HttpCommandBuilder<T> withFallback(final Supplier<T> fallback) {
        this. = ofNullable(fallback);
        return this;
    }
    public HttpCommandBuilder<T> timingOutAfter(final int timeoutfinal TimeUnit timeUnit) {
        this. = timeout;
        this. = requireNonNull(timeUnit);
        return this;
    }
    public HttpCommandBuilder<T> mappedBy(final Function<Response, T> responseMapper) {
        this. = responseMapper;
        return this;
    }
    public HystrixCommand<T> build() {
        return new HttpCommand<T>(
                requireNonNull("Missing Setter"),
                requireNonNull("Missing request builder"),
                ,
                requireNonNull("Missing response mapper"),
                );
    }
    }
New to GrepCode? Check out our FAQ X