diff --git a/spring-web/src/main/java/org/springframework/http/HttpStatus.java b/spring-web/src/main/java/org/springframework/http/HttpStatus.java index 9f80c75282..2153139007 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpStatus.java +++ b/spring-web/src/main/java/org/springframework/http/HttpStatus.java @@ -418,14 +418,14 @@ public enum HttpStatus { private final int value; - private final String reasonPhrase; - private final Series series; + private final String reasonPhrase; + HttpStatus(int value, Series series, String reasonPhrase) { this.value = value; - this.reasonPhrase = reasonPhrase; this.series = series; + this.reasonPhrase = reasonPhrase; } @@ -436,13 +436,6 @@ public enum HttpStatus { return this.value; } - /** - * Return the reason phrase of this status code. - */ - public String getReasonPhrase() { - return this.reasonPhrase; - } - /** * Return the HTTP status series of this status code. * @see HttpStatus.Series @@ -451,10 +444,17 @@ public enum HttpStatus { return this.series; } + /** + * Return the reason phrase of this status code. + */ + public String getReasonPhrase() { + return this.reasonPhrase; + } + /** * Whether this status code is in the HTTP series * {@link org.springframework.http.HttpStatus.Series#INFORMATIONAL}. - * This is a shortcut for checking the value of {@link #series()}. + *
This is a shortcut for checking the value of {@link #series()}. * @since 4.0 * @see #series() */ @@ -465,7 +465,7 @@ public enum HttpStatus { /** * Whether this status code is in the HTTP series * {@link org.springframework.http.HttpStatus.Series#SUCCESSFUL}. - * This is a shortcut for checking the value of {@link #series()}. + *
This is a shortcut for checking the value of {@link #series()}. * @since 4.0 * @see #series() */ @@ -476,7 +476,7 @@ public enum HttpStatus { /** * Whether this status code is in the HTTP series * {@link org.springframework.http.HttpStatus.Series#REDIRECTION}. - * This is a shortcut for checking the value of {@link #series()}. + *
This is a shortcut for checking the value of {@link #series()}. * @since 4.0 * @see #series() */ @@ -487,7 +487,7 @@ public enum HttpStatus { /** * Whether this status code is in the HTTP series * {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}. - * This is a shortcut for checking the value of {@link #series()}. + *
This is a shortcut for checking the value of {@link #series()}. * @since 4.0 * @see #series() */ @@ -498,7 +498,7 @@ public enum HttpStatus { /** * Whether this status code is in the HTTP series * {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}. - * This is a shortcut for checking the value of {@link #series()}. + *
This is a shortcut for checking the value of {@link #series()}. * @since 4.0 * @see #series() */ @@ -510,7 +510,7 @@ public enum HttpStatus { * Whether this status code is in the HTTP series * {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR} or * {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}. - * This is a shortcut for checking the value of {@link #series()}. + *
This is a shortcut for checking the value of {@link #series()}.
* @since 5.0
* @see #is4xxClientError()
* @see #is5xxServerError()
@@ -529,7 +529,7 @@ public enum HttpStatus {
/**
- * Return the enum constant of this type with the specified numeric value.
+ * Return the {@code HttpStatus} enum constant with the specified numeric value.
* @param statusCode the numeric value of the enum to be returned
* @return the enum constant with the specified numeric value
* @throws IllegalArgumentException if this enum has no constant for the specified numeric value
@@ -585,18 +585,20 @@ public enum HttpStatus {
}
/**
- * Return the enum constant of this type with the corresponding series.
- * @param status a standard HTTP status enum value
- * @return the enum constant of this type with the corresponding series
+ * Return the {@code Series} enum constant for the supplied {@code HttpStatus}.
+ * @param status a standard HTTP status enum constant
+ * @return the {@code Series} enum constant for the supplied {@code HttpStatus}
+ * @deprecated as of 5.3, in favor of invoking {@link HttpStatus#series()} directly
*/
+ @Deprecated
public static Series valueOf(HttpStatus status) {
return status.series;
}
/**
- * Return the enum constant of this type with the corresponding series.
+ * Return the {@code Series} enum constant for the supplied status code.
* @param statusCode the HTTP status code (potentially non-standard)
- * @return the enum constant of this type with the corresponding series
+ * @return the {@code Series} enum constant for the supplied status code
* @throws IllegalArgumentException if this enum has no corresponding constant
*/
public static Series valueOf(int statusCode) {
diff --git a/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java b/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java
index 1ee7609d25..cec1f9ad96 100644
--- a/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java
+++ b/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2019 the original author or authors.
+ * Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,13 +27,13 @@ import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Arjen Poutsma
*/
-public class HttpStatusTests {
+class HttpStatusTests {
- private Map