Package org.springframework.web.client.support

# Class RestClientAdapter

java.lang.Object
org.springframework.web.client.support.RestClientAdapter

All Implemented Interfaces:
  `HttpExchangeAdapter`

public final class RestClientAdapter extends Object implements HttpExchangeAdapter
`HttpExchangeAdapter` that enables an `HttpServiceProxyFactory` to use `RestClient` for request execution.

Use static factory methods in this class to create an `HttpServiceProxyFactory` configured with the given `RestClient`.

Since:
  6.1
Author:
  Olga Maciaszek-Sharma, Rossen Stoyanchev

## Method Summary

Modifier and Type
Method
Description
`static RestClientAdapter`
`create(RestClient restClient)`
Create a `RestClientAdapter` for the given `RestClient`.
`void`
`exchange(HttpRequestValues requestValues)`
Perform the given request, and release the response content, if any.
`ResponseEntity<Void>`
`exchangeForBodilessEntity(HttpRequestValues values)`
Variant of `HttpExchangeAdapter.exchange(HttpRequestValues)` with additional access to the response status and headers.
`<T> T`
`exchangeForBody(HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)`
Perform the given request and decode the response content to the given type.
`<T> ResponseEntity<T>`
`exchangeForEntity(HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)`
Variant of `HttpExchangeAdapter.exchangeForBody(HttpRequestValues, ParameterizedTypeReference)` with additional access to the response status and headers.
`HttpHeaders`
`exchangeForHeaders(HttpRequestValues values)`
Perform the given request, release the response content, and return the response headers.
`boolean`
`supportsRequestAttributes()`
Whether the underlying client supports use of request attributes.

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

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

## Method Details

### supportsRequestAttributes

public boolean supportsRequestAttributes()
Description copied from interface: `HttpExchangeAdapter`
Whether the underlying client supports use of request attributes.

Specified by:
  `supportsRequestAttributes` in interface `HttpExchangeAdapter`

### exchange

public void exchange(HttpRequestValues requestValues)
Description copied from interface: `HttpExchangeAdapter`
Perform the given request, and release the response content, if any.

Specified by:
  `exchange` in interface `HttpExchangeAdapter`
Parameters:
  `requestValues` - the request to perform

### exchangeForHeaders

public HttpHeaders exchangeForHeaders(HttpRequestValues values)
Description copied from interface: `HttpExchangeAdapter`
Perform the given request, release the response content, and return the response headers.

Specified by:
  `exchangeForHeaders` in interface `HttpExchangeAdapter`
Parameters:
  `values` - the request to perform
Returns:
  the response headers

### exchangeForBody

@Nullable public <T> T exchangeForBody(HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)
Description copied from interface: `HttpExchangeAdapter`
Perform the given request and decode the response content to the given type.

Specified by:
  `exchangeForBody` in interface `HttpExchangeAdapter`
Type Parameters:
  `T` - the type the response is decoded to
Parameters:
  `values` - the request to perform
  `bodyType` - the target type to decode to
Returns:
  the decoded response body.

### exchangeForBodilessEntity

public ResponseEntity<Void> exchangeForBodilessEntity(HttpRequestValues values)
Description copied from interface: `HttpExchangeAdapter`
Variant of `HttpExchangeAdapter.exchange(HttpRequestValues)` with additional access to the response status and headers.

Specified by:
  `exchangeForBodilessEntity` in interface `HttpExchangeAdapter`
Returns:
  the response entity with status and headers.

### exchangeForEntity

public <T> ResponseEntity<T> exchangeForEntity(HttpRequestValues values, org.springframework.core.ParameterizedTypeReference<T> bodyType)
Description copied from interface: `HttpExchangeAdapter`
Variant of `HttpExchangeAdapter.exchangeForBody(HttpRequestValues, ParameterizedTypeReference)` with additional access to the response status and headers.

Specified by:
  `exchangeForEntity` in interface `HttpExchangeAdapter`
Returns:
  the response entity with status, headers, and body.

### create

public static RestClientAdapter create(RestClient restClient)
Create a `RestClientAdapter` for the given `RestClient`.