Consistent ordering of WebClient.Builder methods
This commit is contained in:
parent
59064f0780
commit
438b40f6d7
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
|
@ -66,11 +66,11 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
|||
@Nullable
|
||||
private ClientHttpConnector connector;
|
||||
|
||||
private ExchangeStrategies exchangeStrategies;
|
||||
|
||||
@Nullable
|
||||
private ExchangeFunction exchangeFunction;
|
||||
|
||||
private ExchangeStrategies exchangeStrategies;
|
||||
|
||||
|
||||
public DefaultWebClientBuilder() {
|
||||
this.exchangeStrategies = ExchangeStrategies.withDefaults();
|
||||
|
|
@ -80,8 +80,8 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
|||
Assert.notNull(other, "DefaultWebClientBuilder must not be null");
|
||||
|
||||
this.baseUrl = other.baseUrl;
|
||||
this.defaultUriVariables =
|
||||
other.defaultUriVariables != null ? new LinkedHashMap<>(other.defaultUriVariables) : null;
|
||||
this.defaultUriVariables = (other.defaultUriVariables != null ?
|
||||
new LinkedHashMap<>(other.defaultUriVariables) : null);
|
||||
this.uriBuilderFactory = other.uriBuilderFactory;
|
||||
if (other.defaultHeaders != null) {
|
||||
this.defaultHeaders = new HttpHeaders();
|
||||
|
|
@ -90,13 +90,13 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
|||
else {
|
||||
this.defaultHeaders = null;
|
||||
}
|
||||
this.defaultCookies =
|
||||
other.defaultCookies != null ? new LinkedMultiValueMap<>(other.defaultCookies) : null;
|
||||
this.defaultCookies = (other.defaultCookies != null ?
|
||||
new LinkedMultiValueMap<>(other.defaultCookies) : null);
|
||||
this.defaultRequest = other.defaultRequest;
|
||||
this.filters = other.filters != null ? new ArrayList<>(other.filters) : null;
|
||||
this.connector = other.connector;
|
||||
this.exchangeFunction = other.exchangeFunction;
|
||||
this.exchangeStrategies = other.exchangeStrategies;
|
||||
this.exchangeFunction = other.exchangeFunction;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -163,12 +163,6 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebClient.Builder clientConnector(ClientHttpConnector connector) {
|
||||
this.connector = connector;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebClient.Builder filter(ExchangeFilterFunction filter) {
|
||||
Assert.notNull(filter, "ExchangeFilterFunction must not be null");
|
||||
|
|
@ -190,8 +184,8 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
|||
}
|
||||
|
||||
@Override
|
||||
public WebClient.Builder exchangeFunction(ExchangeFunction exchangeFunction) {
|
||||
this.exchangeFunction = exchangeFunction;
|
||||
public WebClient.Builder clientConnector(ClientHttpConnector connector) {
|
||||
this.connector = connector;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -202,6 +196,23 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebClient.Builder exchangeFunction(ExchangeFunction exchangeFunction) {
|
||||
this.exchangeFunction = exchangeFunction;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebClient.Builder apply(Consumer<WebClient.Builder> builderConsumer) {
|
||||
builderConsumer.accept(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebClient.Builder clone() {
|
||||
return new DefaultWebClientBuilder(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebClient build() {
|
||||
ExchangeFunction exchange = initExchangeFunction();
|
||||
|
|
@ -245,15 +256,4 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
|
|||
return CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebClient.Builder clone() {
|
||||
return new DefaultWebClientBuilder(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WebClient.Builder apply(Consumer<WebClient.Builder> builderConsumer) {
|
||||
builderConsumer.accept(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,11 +303,6 @@ public interface WebClient {
|
|||
*/
|
||||
Builder exchangeFunction(ExchangeFunction exchangeFunction);
|
||||
|
||||
/**
|
||||
* Clone this {@code WebClient.Builder}.
|
||||
*/
|
||||
Builder clone();
|
||||
|
||||
/**
|
||||
* Apply the given {@code Consumer} to this builder instance.
|
||||
* <p>This can be useful for applying pre-packaged customizations.
|
||||
|
|
@ -315,17 +310,20 @@ public interface WebClient {
|
|||
*/
|
||||
Builder apply(Consumer<Builder> builderConsumer);
|
||||
|
||||
/**
|
||||
* Clone this {@code WebClient.Builder}.
|
||||
*/
|
||||
Builder clone();
|
||||
|
||||
/**
|
||||
* Builder the {@link WebClient} instance.
|
||||
*/
|
||||
WebClient build();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Contract for specifying the URI for a request.
|
||||
*
|
||||
* @param <S> a self reference to the spec type
|
||||
*/
|
||||
interface UriSpec<S extends RequestHeadersSpec<?>> {
|
||||
|
|
@ -359,7 +357,6 @@ public interface WebClient {
|
|||
|
||||
/**
|
||||
* Contract for specifying request headers leading up to the exchange.
|
||||
*
|
||||
* @param <S> a self reference to the spec type
|
||||
*/
|
||||
interface RequestHeadersSpec<S extends RequestHeadersSpec<S>> {
|
||||
|
|
@ -525,9 +522,9 @@ public interface WebClient {
|
|||
* {@linkplain BodyInserters#fromPublisher Publisher inserter}.
|
||||
* For example:
|
||||
* <p><pre>
|
||||
* Mono<Person> personMono = ... ;
|
||||
* Mono<Person> personMono = ... ;
|
||||
*
|
||||
* Mono<Void> result = client.post()
|
||||
* Mono<Void> result = client.post()
|
||||
* .uri("/persons/{id}", id)
|
||||
* .contentType(MediaType.APPLICATION_JSON)
|
||||
* .body(personMono, Person.class)
|
||||
|
|
|
|||
Loading…
Reference in New Issue