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