Skip to content

Commit 438b40f

Browse files
committed
Consistent ordering of WebClient.Builder methods
1 parent 59064f0 commit 438b40f

File tree

2 files changed

+34
-37
lines changed

2 files changed

+34
-37
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultWebClientBuilder.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -66,11 +66,11 @@ final class DefaultWebClientBuilder implements WebClient.Builder {
6666
@Nullable
6767
private ClientHttpConnector connector;
6868

69+
private ExchangeStrategies exchangeStrategies;
70+
6971
@Nullable
7072
private ExchangeFunction exchangeFunction;
7173

72-
private ExchangeStrategies exchangeStrategies;
73-
7474

7575
public DefaultWebClientBuilder() {
7676
this.exchangeStrategies = ExchangeStrategies.withDefaults();
@@ -80,8 +80,8 @@ public DefaultWebClientBuilder(DefaultWebClientBuilder other) {
8080
Assert.notNull(other, "DefaultWebClientBuilder must not be null");
8181

8282
this.baseUrl = other.baseUrl;
83-
this.defaultUriVariables =
84-
other.defaultUriVariables != null ? new LinkedHashMap<>(other.defaultUriVariables) : null;
83+
this.defaultUriVariables = (other.defaultUriVariables != null ?
84+
new LinkedHashMap<>(other.defaultUriVariables) : null);
8585
this.uriBuilderFactory = other.uriBuilderFactory;
8686
if (other.defaultHeaders != null) {
8787
this.defaultHeaders = new HttpHeaders();
@@ -90,13 +90,13 @@ public DefaultWebClientBuilder(DefaultWebClientBuilder other) {
9090
else {
9191
this.defaultHeaders = null;
9292
}
93-
this.defaultCookies =
94-
other.defaultCookies != null ? new LinkedMultiValueMap<>(other.defaultCookies) : null;
93+
this.defaultCookies = (other.defaultCookies != null ?
94+
new LinkedMultiValueMap<>(other.defaultCookies) : null);
9595
this.defaultRequest = other.defaultRequest;
9696
this.filters = other.filters != null ? new ArrayList<>(other.filters) : null;
9797
this.connector = other.connector;
98-
this.exchangeFunction = other.exchangeFunction;
9998
this.exchangeStrategies = other.exchangeStrategies;
99+
this.exchangeFunction = other.exchangeFunction;
100100
}
101101

102102

@@ -163,12 +163,6 @@ public WebClient.Builder defaultRequest(Consumer<WebClient.RequestHeadersSpec<?>
163163
return this;
164164
}
165165

166-
@Override
167-
public WebClient.Builder clientConnector(ClientHttpConnector connector) {
168-
this.connector = connector;
169-
return this;
170-
}
171-
172166
@Override
173167
public WebClient.Builder filter(ExchangeFilterFunction filter) {
174168
Assert.notNull(filter, "ExchangeFilterFunction must not be null");
@@ -190,8 +184,8 @@ private List<ExchangeFilterFunction> initFilters() {
190184
}
191185

192186
@Override
193-
public WebClient.Builder exchangeFunction(ExchangeFunction exchangeFunction) {
194-
this.exchangeFunction = exchangeFunction;
187+
public WebClient.Builder clientConnector(ClientHttpConnector connector) {
188+
this.connector = connector;
195189
return this;
196190
}
197191

@@ -202,6 +196,23 @@ public WebClient.Builder exchangeStrategies(ExchangeStrategies strategies) {
202196
return this;
203197
}
204198

199+
@Override
200+
public WebClient.Builder exchangeFunction(ExchangeFunction exchangeFunction) {
201+
this.exchangeFunction = exchangeFunction;
202+
return this;
203+
}
204+
205+
@Override
206+
public WebClient.Builder apply(Consumer<WebClient.Builder> builderConsumer) {
207+
builderConsumer.accept(this);
208+
return this;
209+
}
210+
211+
@Override
212+
public WebClient.Builder clone() {
213+
return new DefaultWebClientBuilder(this);
214+
}
215+
205216
@Override
206217
public WebClient build() {
207218
ExchangeFunction exchange = initExchangeFunction();
@@ -245,15 +256,4 @@ private static <K, V> MultiValueMap<K, V> unmodifiableCopy(MultiValueMap<K, V> m
245256
return CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(map));
246257
}
247258

248-
@Override
249-
public WebClient.Builder clone() {
250-
return new DefaultWebClientBuilder(this);
251-
}
252-
253-
@Override
254-
public WebClient.Builder apply(Consumer<WebClient.Builder> builderConsumer) {
255-
builderConsumer.accept(this);
256-
return this;
257-
}
258-
259259
}

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -303,29 +303,27 @@ interface Builder {
303303
*/
304304
Builder exchangeFunction(ExchangeFunction exchangeFunction);
305305

306-
/**
307-
* Clone this {@code WebClient.Builder}.
308-
*/
309-
Builder clone();
310-
311306
/**
312307
* Apply the given {@code Consumer} to this builder instance.
313308
* <p>This can be useful for applying pre-packaged customizations.
314309
* @param builderConsumer the consumer to apply
315310
*/
316311
Builder apply(Consumer<Builder> builderConsumer);
317312

313+
/**
314+
* Clone this {@code WebClient.Builder}.
315+
*/
316+
Builder clone();
317+
318318
/**
319319
* Builder the {@link WebClient} instance.
320320
*/
321321
WebClient build();
322-
323322
}
324323

325324

326325
/**
327326
* Contract for specifying the URI for a request.
328-
*
329327
* @param <S> a self reference to the spec type
330328
*/
331329
interface UriSpec<S extends RequestHeadersSpec<?>> {
@@ -359,7 +357,6 @@ interface UriSpec<S extends RequestHeadersSpec<?>> {
359357

360358
/**
361359
* Contract for specifying request headers leading up to the exchange.
362-
*
363360
* @param <S> a self reference to the spec type
364361
*/
365362
interface RequestHeadersSpec<S extends RequestHeadersSpec<S>> {
@@ -525,9 +522,9 @@ interface RequestBodySpec extends RequestHeadersSpec<RequestBodySpec> {
525522
* {@linkplain BodyInserters#fromPublisher Publisher inserter}.
526523
* For example:
527524
* <p><pre>
528-
* Mono<Person> personMono = ... ;
525+
* Mono&lt;Person&gt; personMono = ... ;
529526
*
530-
* Mono<Void> result = client.post()
527+
* Mono&lt;Void&gt; result = client.post()
531528
* .uri("/persons/{id}", id)
532529
* .contentType(MediaType.APPLICATION_JSON)
533530
* .body(personMono, Person.class)

0 commit comments

Comments
 (0)