Package org.springframework.web.service.invoker

# Class HttpRequestValues.Builder

java.lang.Object
org.springframework.web.service.invoker.HttpRequestValues.Builder

All Implemented Interfaces:
  `HttpRequestValues.Metadata`

Direct Known Subclasses:
  `ReactiveHttpRequestValues.Builder`

Enclosing class:
  HttpRequestValues

public static class HttpRequestValues.Builder extends Object implements HttpRequestValues.Metadata
Builder for `HttpRequestValues`.

## Constructor Summary

Constructors
Constructor
Description
`Builder()`

## Method Summary

Modifier and Type
Method
Description
`HttpRequestValues.Builder`
`addAttribute(String name, Object value)`
Configure an attribute to associate with the request.
`HttpRequestValues.Builder`
`addCookie(String name, String... values)`
Add the given cookie name and values.
`HttpRequestValues.Builder`
`addHeader(String headerName, String... headerValues)`
Add the given header name and values.
`HttpRequestValues.Builder`
`addRequestParameter(String name, String... values)`
Add the given request parameter name and values.
`HttpRequestValues.Builder`
`addRequestPart(String name, Object part)`
Add a part for a multipart request.
`HttpRequestValues`
`build()`
Build the `HttpRequestValues` instance.
`protected Object`
`buildMultipartBody()`
`protected HttpRequestValues`
`createRequestValues(HttpMethod httpMethod, URI uri, UriBuilderFactory uriBuilderFactory, String uriTemplate, Map<String,String> uriVars, HttpHeaders headers, org.springframework.util.MultiValueMap<String,String> cookies, Map<String,Object> attributes, Object bodyValue)`
Create `HttpRequestValues` from values passed to the `HttpRequestValues.Builder`.
`List<MediaType>`
`getAcceptMediaTypes()`
Return the acceptable media types, if set already.
`MediaType`
`getContentType()`
Return the content type, if set already.
`HttpMethod`
`getHttpMethod()`
Return the HTTP method, if known.
`String`
`getUriTemplate()`
Return the URI template, if set already.
`protected boolean`
`hasBody()`
`protected boolean`
`hasParts()`
`HttpRequestValues.Builder`
`setAccept(List<MediaType> acceptableMediaTypes)`
Set the media types for the request `Accept` header.
`void`
`setBodyValue(Object bodyValue)`
Set the request body as an Object to be serialized.
`void`
`setBodyValue(Object bodyValue, org.springframework.core.ParameterizedTypeReference<?> valueType)`
Variant of `setBodyValue(Object)` with the body type.
`HttpRequestValues.Builder`
`setContentType(MediaType contentType)`
Set the media type for the request `Content-Type` header.
`HttpRequestValues.Builder`
`setHttpMethod(HttpMethod httpMethod)`
Set the HTTP method for the request.
`HttpRequestValues.Builder`
`setUri(URI uri)`
Set the URL to use.
`HttpRequestValues.Builder`
`setUriBuilderFactory(UriBuilderFactory uriBuilderFactory)`
Set the `UriBuilderFactory` that will be used to expand the `getUriTemplate()`.
`HttpRequestValues.Builder`
`setUriTemplate(String uriTemplate)`
Set the request URL as a String template.
`HttpRequestValues.Builder`
`setUriVariable(String name, String value)`
Add a URI variable name-value pair.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Builder

public Builder()

## Method Details

### setHttpMethod

public HttpRequestValues.Builder setHttpMethod(HttpMethod httpMethod)
Set the HTTP method for the request.

### setUri

public HttpRequestValues.Builder setUri(URI uri)
Set the URL to use. When set, this overrides the URI template from the `HttpExchange` annotation.

### setUriBuilderFactory

public HttpRequestValues.Builder setUriBuilderFactory(@Nullable UriBuilderFactory uriBuilderFactory)
Set the `UriBuilderFactory` that will be used to expand the `getUriTemplate()`.

Since:
  6.1

### setUriTemplate

public HttpRequestValues.Builder setUriTemplate(String uriTemplate)
Set the request URL as a String template.

### setUriVariable

public HttpRequestValues.Builder setUriVariable(String name, String value)
Add a URI variable name-value pair.

### setAccept

public HttpRequestValues.Builder setAccept(List<MediaType> acceptableMediaTypes)
Set the media types for the request `Accept` header.

### setContentType

public HttpRequestValues.Builder setContentType(MediaType contentType)
Set the media type for the request `Content-Type` header.

### addHeader

public HttpRequestValues.Builder addHeader(String headerName, String... headerValues)
Add the given header name and values.

### addCookie

public HttpRequestValues.Builder addCookie(String name, String... values)
Add the given cookie name and values.

### addRequestParameter

public HttpRequestValues.Builder addRequestParameter(String name, String... values)
Add the given request parameter name and values.

When `"content-type"` is set to `"application/x-www-form-urlencoded"`, request parameters are encoded in the request body. Otherwise, they are added as URL query parameters.

### addRequestPart

public HttpRequestValues.Builder addRequestPart(String name, Object part)
Add a part for a multipart request. The part may be:

- String -- form field
- `Resource` -- file part
- Object -- content to be encoded (for example, to JSON)
- `HttpEntity` -- part content and headers although generally it's easier to add headers through the returned builder

### addAttribute

public HttpRequestValues.Builder addAttribute(String name, Object value)
Configure an attribute to associate with the request.

Parameters:
  `name` - the attribute name
  `value` - the attribute value

### setBodyValue

public void setBodyValue(@Nullable Object bodyValue)
Set the request body as an Object to be serialized.

### setBodyValue

public void setBodyValue(@Nullable Object bodyValue, @Nullable org.springframework.core.ParameterizedTypeReference<?> valueType)
Variant of `setBodyValue(Object)` with the body type.

Since:
  6.2.7

### getHttpMethod

@Nullable public HttpMethod getHttpMethod()
Description copied from interface: `HttpRequestValues.Metadata`
Return the HTTP method, if known.

Specified by:
  `getHttpMethod` in interface `HttpRequestValues.Metadata`

### getUriTemplate

@Nullable public String getUriTemplate()
Description copied from interface: `HttpRequestValues.Metadata`
Return the URI template, if set already.

Specified by:
  `getUriTemplate` in interface `HttpRequestValues.Metadata`

### getContentType

@Nullable public MediaType getContentType()
Description copied from interface: `HttpRequestValues.Metadata`
Return the content type, if set already.

Specified by:
  `getContentType` in interface `HttpRequestValues.Metadata`

### getAcceptMediaTypes

@Nullable public List<MediaType> getAcceptMediaTypes()
Description copied from interface: `HttpRequestValues.Metadata`
Return the acceptable media types, if set already.

Specified by:
  `getAcceptMediaTypes` in interface `HttpRequestValues.Metadata`

### build

public HttpRequestValues build()
Build the `HttpRequestValues` instance.

### hasParts

protected boolean hasParts()

### hasBody

protected boolean hasBody()

### buildMultipartBody

protected Object buildMultipartBody()

### createRequestValues

protected HttpRequestValues createRequestValues(@Nullable HttpMethod httpMethod, @Nullable URI uri, @Nullable UriBuilderFactory uriBuilderFactory, @Nullable String uriTemplate, Map<String,String> uriVars, HttpHeaders headers, org.springframework.util.MultiValueMap<String,String> cookies, Map<String,Object> attributes, @Nullable Object bodyValue)
Create `HttpRequestValues` from values passed to the `HttpRequestValues.Builder`.

Since:
  6.1