Class ResponseEntity<T>

java.lang.Object
com.bobocode.bring.web.servlet.http.ResponseEntity<T>
Type Parameters:
T - The type of the response body.

public class ResponseEntity<T> extends Object
Represents an HTTP response entity, containing a response body, headers, and HTTP status. When both ResponseEntity and @ResponseStatus are used in a controller method, the HTTP status from ResponseEntity takes precedence over the one specified by @ResponseStatus.
  • Field Details

    • headers

      private final HttpHeaders headers
    • body

      private final T body
    • httpStatus

      private final HttpStatus httpStatus
  • Constructor Details

    • ResponseEntity

      public ResponseEntity(T body, HttpHeaders headers, HttpStatus httpStatus)
      Constructs a new ResponseEntity with the given body, headers, and HTTP status.
      Parameters:
      body - The response body.
      headers - The headers to be included in the response.
      httpStatus - The HTTP status of the response.
    • ResponseEntity

      public ResponseEntity(T body, HttpStatus httpStatus)
      Constructs a new ResponseEntity with the given body and HTTP status.
      Parameters:
      body - The response body.
      httpStatus - The HTTP status of the response.
    • ResponseEntity

      public ResponseEntity(HttpHeaders headers, HttpStatus httpStatus)
      Constructs a new ResponseEntity with the given headers and HTTP status.
      Parameters:
      headers - The headers to be included in the response.
      httpStatus - The HTTP status of the response.
  • Method Details

    • getHeaders

      public HttpHeaders getHeaders()
      Gets the headers included in the response.
      Returns:
      The headers of the response.
    • getBody

      public T getBody()
      Gets the body of the response.
      Returns:
      The response body.
    • getHttpStatus

      public HttpStatus getHttpStatus()
      Gets the HTTP status of the response.
      Returns:
      The HTTP status.