Polish method order

This commit is contained in:
Rossen Stoyanchev 2019-08-20 09:12:36 +03:00
parent 008687d5ae
commit b75674f5e9
6 changed files with 132 additions and 132 deletions

View File

@ -266,18 +266,6 @@ class DefaultWebTestClient implements WebTestClient {
return this;
}
@Override
public RequestHeadersSpec<?> body(Object producer, Class<?> elementClass) {
this.bodySpec.body(producer, elementClass);
return this;
}
@Override
public RequestHeadersSpec<?> body(Object producer, ParameterizedTypeReference<?> elementTypeRef) {
this.bodySpec.body(producer, elementTypeRef);
return this;
}
@Override
public <T, S extends Publisher<T>> RequestHeadersSpec<?> body(S publisher, Class<T> elementClass) {
this.bodySpec.body(publisher, elementClass);
@ -290,6 +278,18 @@ class DefaultWebTestClient implements WebTestClient {
return this;
}
@Override
public RequestHeadersSpec<?> body(Object producer, Class<?> elementClass) {
this.bodySpec.body(producer, elementClass);
return this;
}
@Override
public RequestHeadersSpec<?> body(Object producer, ParameterizedTypeReference<?> elementTypeRef) {
this.bodySpec.body(producer, elementTypeRef);
return this;
}
@Override
public RequestHeadersSpec<?> body(BodyInserter<?, ? super ClientHttpRequest> inserter) {
this.bodySpec.body(inserter);

View File

@ -644,6 +644,27 @@ public interface WebTestClient {
*/
RequestHeadersSpec<?> bodyValue(Object body);
/**
* Set the body of the request to the given asynchronous {@code Publisher}.
* @param publisher the request body data
* @param elementClass the class of elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <S> the type of the {@code Publisher}
* @return spec for decoding the response
*/
<T, S extends Publisher<T>> RequestHeadersSpec<?> body(S publisher, Class<T> elementClass);
/**
* Set the body of the request to the given asynchronous {@code Publisher}.
* @param publisher the request body data
* @param elementTypeRef the type reference of elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <S> the type of the {@code Publisher}
* @return spec for decoding the response
* @since 5.2
*/
<T, S extends Publisher<T>> RequestHeadersSpec<?> body(S publisher, ParameterizedTypeReference<T> elementTypeRef);
/**
* Set the body of the request to the given producer.
* @param producer the producer to write to the request. This must be a
@ -666,27 +687,6 @@ public interface WebTestClient {
*/
RequestHeadersSpec<?> body(Object producer, ParameterizedTypeReference<?> elementTypeRef);
/**
* Set the body of the request to the given asynchronous {@code Publisher}.
* @param publisher the request body data
* @param elementClass the class of elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <S> the type of the {@code Publisher}
* @return spec for decoding the response
*/
<T, S extends Publisher<T>> RequestHeadersSpec<?> body(S publisher, Class<T> elementClass);
/**
* Set the body of the request to the given asynchronous {@code Publisher}.
* @param publisher the request body data
* @param elementTypeRef the type reference of elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <S> the type of the {@code Publisher}
* @return spec for decoding the response
* @since 5.2
*/
<T, S extends Publisher<T>> RequestHeadersSpec<?> body(S publisher, ParameterizedTypeReference<T> elementTypeRef);
/**
* Set the body of the request to the given {@code BodyInserter}.
* @param inserter the inserter

View File

@ -293,18 +293,6 @@ class DefaultWebClient implements WebClient {
return this;
}
@Override
public RequestHeadersSpec<?> body(Object producer, Class<?> elementClass) {
this.inserter = BodyInserters.fromProducer(producer, elementClass);
return this;
}
@Override
public RequestHeadersSpec<?> body(Object producer, ParameterizedTypeReference<?> elementTypeRef) {
this.inserter = BodyInserters.fromProducer(producer, elementTypeRef);
return this;
}
@Override
public <T, P extends Publisher<T>> RequestHeadersSpec<?> body(
P publisher, ParameterizedTypeReference<T> elementTypeRef) {
@ -318,6 +306,18 @@ class DefaultWebClient implements WebClient {
return this;
}
@Override
public RequestHeadersSpec<?> body(Object producer, Class<?> elementClass) {
this.inserter = BodyInserters.fromProducer(producer, elementClass);
return this;
}
@Override
public RequestHeadersSpec<?> body(Object producer, ParameterizedTypeReference<?> elementTypeRef) {
this.inserter = BodyInserters.fromProducer(producer, elementTypeRef);
return this;
}
@Override
public RequestHeadersSpec<?> body(BodyInserter<?, ? super ClientHttpRequest> inserter) {
this.inserter = inserter;

View File

@ -549,6 +549,41 @@ public interface WebClient {
*/
RequestHeadersSpec<?> bodyValue(Object body);
/**
* A shortcut for {@link #body(BodyInserter)} with a
* {@linkplain BodyInserters#fromPublisher Publisher inserter}.
* For example:
* <p><pre>
* Mono&lt;Person&gt; personMono = ... ;
*
* Mono&lt;Void&gt; result = client.post()
* .uri("/persons/{id}", id)
* .contentType(MediaType.APPLICATION_JSON)
* .body(personMono, Person.class)
* .retrieve()
* .bodyToMono(Void.class);
* </pre>
* @param publisher the {@code Publisher} to write to the request
* @param elementClass the class of elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <P> the type of the {@code Publisher}
* @return this builder
*/
<T, P extends Publisher<T>> RequestHeadersSpec<?> body(P publisher, Class<T> elementClass);
/**
* A variant of {@link #body(Publisher, Class)} that allows providing
* element type information that includes generics via a
* {@link ParameterizedTypeReference}.
* @param publisher the {@code Publisher} to write to the request
* @param elementTypeRef the type reference of elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <P> the type of the {@code Publisher}
* @return this builder
*/
<T, P extends Publisher<T>> RequestHeadersSpec<?> body(P publisher,
ParameterizedTypeReference<T> elementTypeRef);
/**
* A shortcut for {@link #body(BodyInserter)} with a
* {@linkplain BodyInserters#fromProducer inserter}.
@ -585,41 +620,6 @@ public interface WebClient {
*/
RequestHeadersSpec<?> body(Object producer, ParameterizedTypeReference<?> elementTypeRef);
/**
* A shortcut for {@link #body(BodyInserter)} with a
* {@linkplain BodyInserters#fromPublisher Publisher inserter}.
* For example:
* <p><pre>
* Mono&lt;Person&gt; personMono = ... ;
*
* Mono&lt;Void&gt; result = client.post()
* .uri("/persons/{id}", id)
* .contentType(MediaType.APPLICATION_JSON)
* .body(personMono, Person.class)
* .retrieve()
* .bodyToMono(Void.class);
* </pre>
* @param publisher the {@code Publisher} to write to the request
* @param elementClass the class of elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <P> the type of the {@code Publisher}
* @return this builder
*/
<T, P extends Publisher<T>> RequestHeadersSpec<?> body(P publisher, Class<T> elementClass);
/**
* A variant of {@link #body(Publisher, Class)} that allows providing
* element type information that includes generics via a
* {@link ParameterizedTypeReference}.
* @param publisher the {@code Publisher} to write to the request
* @param elementTypeRef the type reference of elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <P> the type of the {@code Publisher}
* @return this builder
*/
<T, P extends Publisher<T>> RequestHeadersSpec<?> body(P publisher,
ParameterizedTypeReference<T> elementTypeRef);
/**
* Set the body of the request using the given body inserter.
* {@link BodyInserters} provides access to built-in implementations of

View File

@ -234,30 +234,6 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
.map(entityResponse -> entityResponse);
}
@Override
public Mono<ServerResponse> body(Object producer, Class<?> elementClass) {
return new DefaultEntityResponseBuilder<>(producer,
BodyInserters.fromProducer(producer, elementClass))
.status(this.statusCode)
.headers(this.headers)
.cookies(cookies -> cookies.addAll(this.cookies))
.hints(hints -> hints.putAll(this.hints))
.build()
.map(entityResponse -> entityResponse);
}
@Override
public Mono<ServerResponse> body(Object producer, ParameterizedTypeReference<?> elementTypeRef) {
return new DefaultEntityResponseBuilder<>(producer,
BodyInserters.fromProducer(producer, elementTypeRef))
.status(this.statusCode)
.headers(this.headers)
.cookies(cookies -> cookies.addAll(this.cookies))
.hints(hints -> hints.putAll(this.hints))
.build()
.map(entityResponse -> entityResponse);
}
@Override
public <T, P extends Publisher<T>> Mono<ServerResponse> body(P publisher, Class<T> elementClass) {
return new DefaultEntityResponseBuilder<>(publisher,
@ -284,9 +260,27 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
}
@Override
@Deprecated
public Mono<ServerResponse> syncBody(Object body) {
return bodyValue(body);
public Mono<ServerResponse> body(Object producer, Class<?> elementClass) {
return new DefaultEntityResponseBuilder<>(producer,
BodyInserters.fromProducer(producer, elementClass))
.status(this.statusCode)
.headers(this.headers)
.cookies(cookies -> cookies.addAll(this.cookies))
.hints(hints -> hints.putAll(this.hints))
.build()
.map(entityResponse -> entityResponse);
}
@Override
public Mono<ServerResponse> body(Object producer, ParameterizedTypeReference<?> elementTypeRef) {
return new DefaultEntityResponseBuilder<>(producer,
BodyInserters.fromProducer(producer, elementTypeRef))
.status(this.statusCode)
.headers(this.headers)
.cookies(cookies -> cookies.addAll(this.cookies))
.hints(hints -> hints.putAll(this.hints))
.build()
.map(entityResponse -> entityResponse);
}
@Override
@ -295,6 +289,12 @@ class DefaultServerResponseBuilder implements ServerResponse.BodyBuilder {
new BodyInserterResponse<>(this.statusCode, this.headers, this.cookies, inserter, this.hints));
}
@Override
@Deprecated
public Mono<ServerResponse> syncBody(Object body) {
return bodyValue(body);
}
@Override
public Mono<ServerResponse> render(String name, Object... modelAttributes) {
return new DefaultRenderingResponseBuilder(name)

View File

@ -410,6 +410,31 @@ public interface ServerResponse {
*/
Mono<ServerResponse> bodyValue(Object body);
/**
* Set the body of the response to the given asynchronous {@code Publisher} and return it.
* This convenience method combines {@link #body(BodyInserter)} and
* {@link BodyInserters#fromPublisher(Publisher, Class)}.
* @param publisher the {@code Publisher} to write to the response
* @param elementClass the class of elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <P> the type of the {@code Publisher}
* @return the built response
*/
<T, P extends Publisher<T>> Mono<ServerResponse> body(P publisher, Class<T> elementClass);
/**
* Set the body of the response to the given asynchronous {@code Publisher} and return it.
* This convenience method combines {@link #body(BodyInserter)} and
* {@link BodyInserters#fromPublisher(Publisher, ParameterizedTypeReference)}.
* @param publisher the {@code Publisher} to write to the response
* @param elementTypeRef a type reference describing the elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <P> the type of the {@code Publisher}
* @return the built response
*/
<T, P extends Publisher<T>> Mono<ServerResponse> body(P publisher,
ParameterizedTypeReference<T> elementTypeRef);
/**
* Set the body of the response to the given asynchronous {@code Publisher} and return it.
* This convenience method combines {@link #body(BodyInserter)} and
@ -436,31 +461,6 @@ public interface ServerResponse {
*/
Mono<ServerResponse> body(Object producer, ParameterizedTypeReference<?> elementTypeRef);
/**
* Set the body of the response to the given asynchronous {@code Publisher} and return it.
* This convenience method combines {@link #body(BodyInserter)} and
* {@link BodyInserters#fromPublisher(Publisher, Class)}.
* @param publisher the {@code Publisher} to write to the response
* @param elementClass the class of elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <P> the type of the {@code Publisher}
* @return the built response
*/
<T, P extends Publisher<T>> Mono<ServerResponse> body(P publisher, Class<T> elementClass);
/**
* Set the body of the response to the given asynchronous {@code Publisher} and return it.
* This convenience method combines {@link #body(BodyInserter)} and
* {@link BodyInserters#fromPublisher(Publisher, ParameterizedTypeReference)}.
* @param publisher the {@code Publisher} to write to the response
* @param elementTypeRef a type reference describing the elements contained in the publisher
* @param <T> the type of the elements contained in the publisher
* @param <P> the type of the {@code Publisher}
* @return the built response
*/
<T, P extends Publisher<T>> Mono<ServerResponse> body(P publisher,
ParameterizedTypeReference<T> elementTypeRef);
/**
* Set the body of the response to the given {@code BodyInserter} and return it.
* @param inserter the {@code BodyInserter} that writes to the response