Partager via


SimpleResponse<T> Class

  • java.lang.Object
    • com.azure.core.http.rest.SimpleResponse<T>

Type Parameters

T

The type of the deserialized response content.

Implements

public class SimpleResponse
implements Response<T>

This class represents a simple HTTP response with a strongly-typed content. It encapsulates the HTTP request that resulted in the response, the status code of the HTTP response, the headers of the HTTP response, and the deserialized value of the HTTP response.

This class is useful when you want to work with the response of an HTTP request where the body of the response is expected to be in a specific format (the generic type T).

Constructor Summary

Constructor Description
SimpleResponse(HttpRequest request, int statusCode, HttpHeaders headers, T value)

Creates a SimpleResponse<T>.

SimpleResponse(Response<?> response, T value)

Creates a SimpleResponse<T> from a response and a value.

Method Summary

Modifier and Type Method and Description
HttpHeaders getHeaders()

Gets the headers from the HTTP response.

HttpRequest getRequest()

Gets the request which resulted in this SimpleResponse<T>.

int getStatusCode()

Gets the status code of the HTTP response.

T getValue()

Gets the deserialized value of the HTTP response.

Methods inherited from java.lang.Object

Constructor Details

SimpleResponse

public SimpleResponse(HttpRequest request, int statusCode, HttpHeaders headers, T value)

Creates a SimpleResponse<T>.

Parameters:

request - The request which resulted in this response.
statusCode - The status code of the HTTP response.
headers - The headers of the HTTP response.
value - The deserialized value of the HTTP response.

SimpleResponse

public SimpleResponse(Response response, T value)

Creates a SimpleResponse<T> from a response and a value.

Parameters:

response - The response that needs to be mapped.
value - The value to put into the new response.

Method Details

getHeaders

public HttpHeaders getHeaders()

Gets the headers from the HTTP response.

getRequest

public HttpRequest getRequest()

Gets the request which resulted in this SimpleResponse<T>.

Returns:

The request which resulted in this SimpleResponse<T>.

getStatusCode

public int getStatusCode()

Gets the status code of the HTTP response.

Returns:

The status code of the HTTP response.

getValue

public T getValue()

Gets the deserialized value of the HTTP response.

Returns:

The deserialized value of the HTTP response.

Applies to