FeignClientBuilder.Builder should always return the generic builder (#215)

* FeignClientBuilder should always return the generic builder

* Test also FeignClientBuilder.Builder ContextId
This commit is contained in:
Robert Resch
2019-09-26 17:00:54 +02:00
committed by Olga Maciaszek-Sharma
parent 7eb7067752
commit 1e1562b24a
2 changed files with 9 additions and 9 deletions

View File

@@ -62,33 +62,33 @@ public class FeignClientBuilder {
this.url("").path("").decode404(false);
}
public Builder url(final String url) {
public Builder<T> url(final String url) {
this.feignClientFactoryBean.setUrl(FeignClientsRegistrar.getUrl(url));
return this;
}
public Builder contextId(final String contextId) {
public Builder<T> contextId(final String contextId) {
this.feignClientFactoryBean.setContextId(contextId);
return this;
}
public Builder path(final String path) {
public Builder<T> path(final String path) {
this.feignClientFactoryBean.setPath(FeignClientsRegistrar.getPath(path));
return this;
}
public Builder decode404(final boolean decode404) {
public Builder<T> decode404(final boolean decode404) {
this.feignClientFactoryBean.setDecode404(decode404);
return this;
}
public Builder fallback(final Class<? extends T> fallback) {
public Builder<T> fallback(final Class<? extends T> fallback) {
FeignClientsRegistrar.validateFallback(fallback);
this.feignClientFactoryBean.setFallback(fallback);
return this;
}
public Builder fallbackFactory(
public Builder<T> fallbackFactory(
final Class<? extends FallbackFactory<? extends T>> fallbackFactory) {
FeignClientsRegistrar.validateFallbackFactory(fallbackFactory);
this.feignClientFactoryBean.setFallbackFactory(fallbackFactory);
@@ -96,10 +96,9 @@ public class FeignClientBuilder {
}
/**
* @param <T> the target type of the Feign client to be created
* @return the created Feign client
*/
public <T> T build() {
public T build() {
return this.feignClientFactoryBean.getTarget();
}

View File

@@ -130,12 +130,13 @@ public class FeignClientBuilderTests {
.forType(TestFeignClient.class, "TestClient").decode404(true)
.fallback(TestFeignClientFallback.class)
.fallbackFactory(TestFeignClientFallbackFactory.class).path("Path/")
.url("Url/");
.url("Url/").contextId("TestContext");
// then:
assertFactoryBeanField(builder, "applicationContext", this.applicationContext);
assertFactoryBeanField(builder, "type", TestFeignClient.class);
assertFactoryBeanField(builder, "name", "TestClient");
assertFactoryBeanField(builder, "contextId", "TestContext");
// and:
assertFactoryBeanField(builder, "url", "http://Url/");