org.springframework.web.reactive.function.client.support

Class ClientResponseWrapper

  • java.lang.Object
    • org.springframework.web.reactive.function.client.support.ClientResponseWrapper
  • All Implemented Interfaces:
    ClientResponse


    public class ClientResponseWrapper
    extends java.lang.Object
    implements ClientResponse
    Implementation of the ClientResponse interface that can be subclassed to adapt the request in a exchange filter function. All methods default to calling through to the wrapped request.
    Since:
    5.0.5
    Author:
    Arjen Poutsma
    • Constructor Detail

      • ClientResponseWrapper

        public ClientResponseWrapper(ClientResponse delegate)
        Create a new ClientResponseWrapper that wraps the given response.
        Parameters:
        delegate - the response to wrap
    • Method Detail

      • response

        public ClientResponse response()
        Return the wrapped request.
      • body

        public <T> T body(BodyExtractor<T,? super ClientHttpResponse> extractor)
        Description copied from interface: ClientResponse
        Extract the body with the given BodyExtractor.
        Specified by:
        body in interface ClientResponse
        Type Parameters:
        T - the type of the body returned
        Parameters:
        extractor - the BodyExtractor that reads from the response
        Returns:
        the extracted body
      • bodyToMono

        public <T> reactor.core.publisher.Mono<T> bodyToMono(java.lang.Class<? extends T> elementClass)
        Description copied from interface: ClientResponse
        Extract the body to a Mono.
        Specified by:
        bodyToMono in interface ClientResponse
        Type Parameters:
        T - the element type
        Parameters:
        elementClass - the class of element in the Mono
        Returns:
        a mono containing the body of the given type T
      • bodyToMono

        public <T> reactor.core.publisher.Mono<T> bodyToMono(ParameterizedTypeReference<T> typeReference)
        Description copied from interface: ClientResponse
        Extract the body to a Mono.
        Specified by:
        bodyToMono in interface ClientResponse
        Type Parameters:
        T - the element type
        Parameters:
        typeReference - a type reference describing the expected response body type
        Returns:
        a mono containing the body of the given type T
      • bodyToFlux

        public <T> reactor.core.publisher.Flux<T> bodyToFlux(java.lang.Class<? extends T> elementClass)
        Description copied from interface: ClientResponse
        Extract the body to a Flux.
        Specified by:
        bodyToFlux in interface ClientResponse
        Type Parameters:
        T - the element type
        Parameters:
        elementClass - the class of element in the Flux
        Returns:
        a flux containing the body of the given type T
      • bodyToFlux

        public <T> reactor.core.publisher.Flux<T> bodyToFlux(ParameterizedTypeReference<T> typeReference)
        Description copied from interface: ClientResponse
        Extract the body to a Flux.
        Specified by:
        bodyToFlux in interface ClientResponse
        Type Parameters:
        T - the element type
        Parameters:
        typeReference - a type reference describing the expected response body type
        Returns:
        a flux containing the body of the given type T
      • toEntity

        public <T> reactor.core.publisher.Mono<ResponseEntity<T>> toEntity(java.lang.Class<T> bodyType)
        Description copied from interface: ClientResponse
        Return this response as a delayed ResponseEntity.
        Specified by:
        toEntity in interface ClientResponse
        Type Parameters:
        T - response body type
        Parameters:
        bodyType - the expected response body type
        Returns:
        Mono with the ResponseEntity
      • toEntity

        public <T> reactor.core.publisher.Mono<ResponseEntity<T>> toEntity(ParameterizedTypeReference<T> typeReference)
        Description copied from interface: ClientResponse
        Return this response as a delayed ResponseEntity.
        Specified by:
        toEntity in interface ClientResponse
        Type Parameters:
        T - response body type
        Parameters:
        typeReference - a type reference describing the expected response body type
        Returns:
        Mono with the ResponseEntity
      • toEntityList

        public <T> reactor.core.publisher.Mono<ResponseEntity<java.util.List<T>>> toEntityList(java.lang.Class<T> elementType)
        Description copied from interface: ClientResponse
        Return this response as a delayed list of ResponseEntitys.
        Specified by:
        toEntityList in interface ClientResponse
        Type Parameters:
        T - the type of elements in the list
        Parameters:
        elementType - the expected response body list element type
        Returns:
        Mono with the list of ResponseEntitys
      • toEntityList

        public <T> reactor.core.publisher.Mono<ResponseEntity<java.util.List<T>>> toEntityList(ParameterizedTypeReference<T> typeReference)
        Description copied from interface: ClientResponse
        Return this response as a delayed list of ResponseEntitys.
        Specified by:
        toEntityList in interface ClientResponse
        Type Parameters:
        T - the type of elements in the list
        Parameters:
        typeReference - a type reference describing the expected response body type
        Returns:
        Mono with the list of ResponseEntitys