Package org.springframework.http

# Interface HttpStatusCode

All Superinterfaces:
  `Serializable`

All Known Implementing Classes:
  `HttpStatus`

public sealed interface HttpStatusCode extends Serializable permits HttpStatus (not exhaustive)
Represents an HTTP response status code. Implemented by `HttpStatus`, but defined as an interface to allow for values not in that enumeration.

Since:
  6.0
Author:
  Arjen Poutsma
See Also:
  - HTTP Status Code Registry
  - List of HTTP status codes - Wikipedia

## Method Summary

Modifier and Type
Method
Description
`boolean`
`is1xxInformational()`
Whether this status code is in the Informational class (`1xx`).
`boolean`
`is2xxSuccessful()`
Whether this status code is in the Successful class (`2xx`).
`boolean`
`is3xxRedirection()`
Whether this status code is in the Redirection class (`3xx`).
`boolean`
`is4xxClientError()`
Whether this status code is in the Client Error class (`4xx`).
`boolean`
`is5xxServerError()`
Whether this status code is in the Server Error class (`5xx`).
`boolean`
`isError()`
Whether this status code is in the Client or Server Error class
`default boolean`
`isSameCodeAs(HttpStatusCode other)`
Whether this `HttpStatusCode` shares the same integer `value` as the other status code.
`int`
`value()`
Return the integer value of this status code.
`static HttpStatusCode`
`valueOf(int code)`
Return an `HttpStatusCode` object for the given integer value.

## Method Details

### value

int value()
Return the integer value of this status code.

### is1xxInformational

boolean is1xxInformational()
Whether this status code is in the Informational class (`1xx`).

See Also:
  - RFC 2616

### is2xxSuccessful

boolean is2xxSuccessful()
Whether this status code is in the Successful class (`2xx`).

See Also:
  - RFC 2616

### is3xxRedirection

boolean is3xxRedirection()
Whether this status code is in the Redirection class (`3xx`).

See Also:
  - RFC 2616

### is4xxClientError

boolean is4xxClientError()
Whether this status code is in the Client Error class (`4xx`).

See Also:
  - RFC 2616

### is5xxServerError

boolean is5xxServerError()
Whether this status code is in the Server Error class (`5xx`).

See Also:
  - RFC 2616

### isError

boolean isError()
Whether this status code is in the Client or Server Error class

See Also:
  - RFC 2616
  - RFC 2616 (`4xx` or `5xx`).
  - `is4xxClientError()`
  - `is5xxServerError()`

### isSameCodeAs

default boolean isSameCodeAs(HttpStatusCode other)
Whether this `HttpStatusCode` shares the same integer `value` as the other status code.

Useful for comparisons that take deprecated aliases into account or compare arbitrary implementations of `HttpStatusCode` (for example, in place of `HttpStatus enum equality`).

Parameters:
  `other` - the other `HttpStatusCode` to compare
Returns:
  true if the two `HttpStatusCode` objects share the same integer `value()`, false otherwise
Since:
  6.0.5

### valueOf

static HttpStatusCode valueOf(int code)
Return an `HttpStatusCode` object for the given integer value.

Parameters:
  `code` - the status code as integer
Returns:
  the corresponding `HttpStatusCode`
Throws:
  `IllegalArgumentException` - if `code` is not a three-digit positive number