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

com.github.mlk.guice.FeignSuppler Maven / Gradle / Ivy

The newest version!
package com.github.mlk.guice;

import com.google.inject.Inject;
import com.google.inject.Injector;
import feign.Feign;

import java.util.function.Function;

class FeignSuppler implements Function, Object> {
    private final Feign.Builder builder;
    private final String url;
    private Injector injector;

    FeignSuppler(Feign.Builder builder, String url) {
        this.builder = builder;
        this.url = url;
    }

    @Inject
    public void setInjector(Injector injector) {
        this.injector = injector;
    }

    @Override
    public Object apply(Class aClass) {
        Feign.Builder builder = this.builder;
        if(builder == null) {
            builder = injector.getInstance(Feign.Builder.class);
        }
        return builder.target(aClass, url);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy