final class DefaultClientRequestBuilder extends java.lang.Object implements ClientRequest.Builder
ClientRequest.Builder
.Modifier and Type | Class and Description |
---|---|
private static class |
DefaultClientRequestBuilder.BodyInserterRequest |
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.Object> |
attributes |
private BodyInserter<?,? super ClientHttpRequest> |
body |
private MultiValueMap<java.lang.String,java.lang.String> |
cookies |
private HttpHeaders |
headers |
private HttpMethod |
method |
private java.net.URI |
url |
Constructor and Description |
---|
DefaultClientRequestBuilder(ClientRequest other) |
DefaultClientRequestBuilder(HttpMethod method,
java.net.URI url) |
Modifier and Type | Method and Description |
---|---|
ClientRequest.Builder |
attribute(java.lang.String name,
java.lang.Object value)
Set the attribute with the given name to the given value.
|
ClientRequest.Builder |
attributes(java.util.function.Consumer<java.util.Map<java.lang.String,java.lang.Object>> attributesConsumer)
Manipulate the request attributes with the given consumer.
|
ClientRequest.Builder |
body(BodyInserter<?,? super ClientHttpRequest> inserter)
Set the body of the request to the given
BodyInserter . |
<S,P extends <any>> |
body(P publisher,
java.lang.Class<S> elementClass)
Set the body of the request to the given
Publisher and return it. |
<S,P extends <any>> |
body(P publisher,
ParameterizedTypeReference<S> typeReference)
Set the body of the request to the given
Publisher and return it. |
ClientRequest |
build()
Build the request.
|
ClientRequest.Builder |
cookie(java.lang.String name,
java.lang.String... values)
Add a cookie with the given name and value(s).
|
ClientRequest.Builder |
cookies(java.util.function.Consumer<MultiValueMap<java.lang.String,java.lang.String>> cookiesConsumer)
Manipulate this request's cookies with the given consumer.
|
ClientRequest.Builder |
header(java.lang.String headerName,
java.lang.String... headerValues)
Add the given header value(s) under the given name.
|
ClientRequest.Builder |
headers(java.util.function.Consumer<HttpHeaders> headersConsumer)
Manipulate this request's headers with the given consumer.
|
ClientRequest.Builder |
method(HttpMethod method)
Set the method of the request.
|
ClientRequest.Builder |
url(java.net.URI url)
Set the url of the request.
|
private HttpMethod method
private java.net.URI url
private final HttpHeaders headers
private final MultiValueMap<java.lang.String,java.lang.String> cookies
private final java.util.Map<java.lang.String,java.lang.Object> attributes
private BodyInserter<?,? super ClientHttpRequest> body
public DefaultClientRequestBuilder(ClientRequest other)
public DefaultClientRequestBuilder(HttpMethod method, java.net.URI url)
public ClientRequest.Builder method(HttpMethod method)
ClientRequest.Builder
method
in interface ClientRequest.Builder
method
- the new methodpublic ClientRequest.Builder url(java.net.URI url)
ClientRequest.Builder
url
in interface ClientRequest.Builder
url
- the new urlpublic ClientRequest.Builder header(java.lang.String headerName, java.lang.String... headerValues)
ClientRequest.Builder
header
in interface ClientRequest.Builder
headerName
- the header nameheaderValues
- the header value(s)HttpHeaders.add(String, String)
public ClientRequest.Builder headers(java.util.function.Consumer<HttpHeaders> headersConsumer)
ClientRequest.Builder
HttpHeaders
methods.headers
in interface ClientRequest.Builder
headersConsumer
- a function that consumes the HttpHeaders
public ClientRequest.Builder cookie(java.lang.String name, java.lang.String... values)
ClientRequest.Builder
cookie
in interface ClientRequest.Builder
name
- the cookie namevalues
- the cookie value(s)public ClientRequest.Builder cookies(java.util.function.Consumer<MultiValueMap<java.lang.String,java.lang.String>> cookiesConsumer)
ClientRequest.Builder
MultiValueMap
methods.cookies
in interface ClientRequest.Builder
cookiesConsumer
- a function that consumes the cookies mappublic <S,P extends <any>> ClientRequest.Builder body(P publisher, java.lang.Class<S> elementClass)
ClientRequest.Builder
Publisher
and return it.body
in interface ClientRequest.Builder
S
- the type of the elements contained in the publisherP
- the type of the Publisher
publisher
- the Publisher
to write to the requestelementClass
- the class of elements contained in the publisherpublic <S,P extends <any>> ClientRequest.Builder body(P publisher, ParameterizedTypeReference<S> typeReference)
ClientRequest.Builder
Publisher
and return it.body
in interface ClientRequest.Builder
S
- the type of the elements contained in the publisherP
- the type of the Publisher
publisher
- the Publisher
to write to the requesttypeReference
- a type reference describing the elements contained in the publisherpublic ClientRequest.Builder attribute(java.lang.String name, java.lang.Object value)
ClientRequest.Builder
attribute
in interface ClientRequest.Builder
name
- the name of the attribute to addvalue
- the value of the attribute to addpublic ClientRequest.Builder attributes(java.util.function.Consumer<java.util.Map<java.lang.String,java.lang.Object>> attributesConsumer)
ClientRequest.Builder
attributes
in interface ClientRequest.Builder
attributesConsumer
- a function that consumes the attributespublic ClientRequest.Builder body(BodyInserter<?,? super ClientHttpRequest> inserter)
ClientRequest.Builder
BodyInserter
.body
in interface ClientRequest.Builder
inserter
- the BodyInserter
that writes to the requestpublic ClientRequest build()
ClientRequest.Builder
build
in interface ClientRequest.Builder