001/* 002 * Copyright 2002-2019 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.http; 018 019/** 020 * Enumeration of HTTP status codes. 021 * 022 * <p>The HTTP status code series can be retrieved via {@link #series()}. 023 * 024 * @author Arjen Poutsma 025 * @author Sebastien Deleuze 026 * @author Brian Clozel 027 * @since 3.0 028 * @see HttpStatus.Series 029 * @see <a href="https://www.iana.org/assignments/http-status-codes">HTTP Status Code Registry</a> 030 * @see <a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes">List of HTTP status codes - Wikipedia</a> 031 */ 032public enum HttpStatus { 033 034 // 1xx Informational 035 036 /** 037 * {@code 100 Continue}. 038 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.2.1">HTTP/1.1: Semantics and Content, section 6.2.1</a> 039 */ 040 CONTINUE(100, "Continue"), 041 /** 042 * {@code 101 Switching Protocols}. 043 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.2.2">HTTP/1.1: Semantics and Content, section 6.2.2</a> 044 */ 045 SWITCHING_PROTOCOLS(101, "Switching Protocols"), 046 /** 047 * {@code 102 Processing}. 048 * @see <a href="https://tools.ietf.org/html/rfc2518#section-10.1">WebDAV</a> 049 */ 050 PROCESSING(102, "Processing"), 051 /** 052 * {@code 103 Checkpoint}. 053 * @see <a href="https://code.google.com/p/gears/wiki/ResumableHttpRequestsProposal">A proposal for supporting 054 * resumable POST/PUT HTTP requests in HTTP/1.0</a> 055 */ 056 CHECKPOINT(103, "Checkpoint"), 057 058 // 2xx Success 059 060 /** 061 * {@code 200 OK}. 062 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.3.1">HTTP/1.1: Semantics and Content, section 6.3.1</a> 063 */ 064 OK(200, "OK"), 065 /** 066 * {@code 201 Created}. 067 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.3.2">HTTP/1.1: Semantics and Content, section 6.3.2</a> 068 */ 069 CREATED(201, "Created"), 070 /** 071 * {@code 202 Accepted}. 072 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.3.3">HTTP/1.1: Semantics and Content, section 6.3.3</a> 073 */ 074 ACCEPTED(202, "Accepted"), 075 /** 076 * {@code 203 Non-Authoritative Information}. 077 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.3.4">HTTP/1.1: Semantics and Content, section 6.3.4</a> 078 */ 079 NON_AUTHORITATIVE_INFORMATION(203, "Non-Authoritative Information"), 080 /** 081 * {@code 204 No Content}. 082 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.3.5">HTTP/1.1: Semantics and Content, section 6.3.5</a> 083 */ 084 NO_CONTENT(204, "No Content"), 085 /** 086 * {@code 205 Reset Content}. 087 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.3.6">HTTP/1.1: Semantics and Content, section 6.3.6</a> 088 */ 089 RESET_CONTENT(205, "Reset Content"), 090 /** 091 * {@code 206 Partial Content}. 092 * @see <a href="https://tools.ietf.org/html/rfc7233#section-4.1">HTTP/1.1: Range Requests, section 4.1</a> 093 */ 094 PARTIAL_CONTENT(206, "Partial Content"), 095 /** 096 * {@code 207 Multi-Status}. 097 * @see <a href="https://tools.ietf.org/html/rfc4918#section-13">WebDAV</a> 098 */ 099 MULTI_STATUS(207, "Multi-Status"), 100 /** 101 * {@code 208 Already Reported}. 102 * @see <a href="https://tools.ietf.org/html/rfc5842#section-7.1">WebDAV Binding Extensions</a> 103 */ 104 ALREADY_REPORTED(208, "Already Reported"), 105 /** 106 * {@code 226 IM Used}. 107 * @see <a href="https://tools.ietf.org/html/rfc3229#section-10.4.1">Delta encoding in HTTP</a> 108 */ 109 IM_USED(226, "IM Used"), 110 111 // 3xx Redirection 112 113 /** 114 * {@code 300 Multiple Choices}. 115 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.1">HTTP/1.1: Semantics and Content, section 6.4.1</a> 116 */ 117 MULTIPLE_CHOICES(300, "Multiple Choices"), 118 /** 119 * {@code 301 Moved Permanently}. 120 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.2">HTTP/1.1: Semantics and Content, section 6.4.2</a> 121 */ 122 MOVED_PERMANENTLY(301, "Moved Permanently"), 123 /** 124 * {@code 302 Found}. 125 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.3">HTTP/1.1: Semantics and Content, section 6.4.3</a> 126 */ 127 FOUND(302, "Found"), 128 /** 129 * {@code 302 Moved Temporarily}. 130 * @see <a href="https://tools.ietf.org/html/rfc1945#section-9.3">HTTP/1.0, section 9.3</a> 131 * @deprecated in favor of {@link #FOUND} which will be returned from {@code HttpStatus.valueOf(302)} 132 */ 133 @Deprecated 134 MOVED_TEMPORARILY(302, "Moved Temporarily"), 135 /** 136 * {@code 303 See Other}. 137 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.4">HTTP/1.1: Semantics and Content, section 6.4.4</a> 138 */ 139 SEE_OTHER(303, "See Other"), 140 /** 141 * {@code 304 Not Modified}. 142 * @see <a href="https://tools.ietf.org/html/rfc7232#section-4.1">HTTP/1.1: Conditional Requests, section 4.1</a> 143 */ 144 NOT_MODIFIED(304, "Not Modified"), 145 /** 146 * {@code 305 Use Proxy}. 147 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.5">HTTP/1.1: Semantics and Content, section 6.4.5</a> 148 * @deprecated due to security concerns regarding in-band configuration of a proxy 149 */ 150 @Deprecated 151 USE_PROXY(305, "Use Proxy"), 152 /** 153 * {@code 307 Temporary Redirect}. 154 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.4.7">HTTP/1.1: Semantics and Content, section 6.4.7</a> 155 */ 156 TEMPORARY_REDIRECT(307, "Temporary Redirect"), 157 /** 158 * {@code 308 Permanent Redirect}. 159 * @see <a href="https://tools.ietf.org/html/rfc7238">RFC 7238</a> 160 */ 161 PERMANENT_REDIRECT(308, "Permanent Redirect"), 162 163 // --- 4xx Client Error --- 164 165 /** 166 * {@code 400 Bad Request}. 167 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.1">HTTP/1.1: Semantics and Content, section 6.5.1</a> 168 */ 169 BAD_REQUEST(400, "Bad Request"), 170 /** 171 * {@code 401 Unauthorized}. 172 * @see <a href="https://tools.ietf.org/html/rfc7235#section-3.1">HTTP/1.1: Authentication, section 3.1</a> 173 */ 174 UNAUTHORIZED(401, "Unauthorized"), 175 /** 176 * {@code 402 Payment Required}. 177 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.2">HTTP/1.1: Semantics and Content, section 6.5.2</a> 178 */ 179 PAYMENT_REQUIRED(402, "Payment Required"), 180 /** 181 * {@code 403 Forbidden}. 182 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.3">HTTP/1.1: Semantics and Content, section 6.5.3</a> 183 */ 184 FORBIDDEN(403, "Forbidden"), 185 /** 186 * {@code 404 Not Found}. 187 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.4">HTTP/1.1: Semantics and Content, section 6.5.4</a> 188 */ 189 NOT_FOUND(404, "Not Found"), 190 /** 191 * {@code 405 Method Not Allowed}. 192 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.5">HTTP/1.1: Semantics and Content, section 6.5.5</a> 193 */ 194 METHOD_NOT_ALLOWED(405, "Method Not Allowed"), 195 /** 196 * {@code 406 Not Acceptable}. 197 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.6">HTTP/1.1: Semantics and Content, section 6.5.6</a> 198 */ 199 NOT_ACCEPTABLE(406, "Not Acceptable"), 200 /** 201 * {@code 407 Proxy Authentication Required}. 202 * @see <a href="https://tools.ietf.org/html/rfc7235#section-3.2">HTTP/1.1: Authentication, section 3.2</a> 203 */ 204 PROXY_AUTHENTICATION_REQUIRED(407, "Proxy Authentication Required"), 205 /** 206 * {@code 408 Request Timeout}. 207 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.7">HTTP/1.1: Semantics and Content, section 6.5.7</a> 208 */ 209 REQUEST_TIMEOUT(408, "Request Timeout"), 210 /** 211 * {@code 409 Conflict}. 212 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.8">HTTP/1.1: Semantics and Content, section 6.5.8</a> 213 */ 214 CONFLICT(409, "Conflict"), 215 /** 216 * {@code 410 Gone}. 217 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.9">HTTP/1.1: Semantics and Content, section 6.5.9</a> 218 */ 219 GONE(410, "Gone"), 220 /** 221 * {@code 411 Length Required}. 222 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.10">HTTP/1.1: Semantics and Content, section 6.5.10</a> 223 */ 224 LENGTH_REQUIRED(411, "Length Required"), 225 /** 226 * {@code 412 Precondition failed}. 227 * @see <a href="https://tools.ietf.org/html/rfc7232#section-4.2">HTTP/1.1: Conditional Requests, section 4.2</a> 228 */ 229 PRECONDITION_FAILED(412, "Precondition Failed"), 230 /** 231 * {@code 413 Payload Too Large}. 232 * @since 4.1 233 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.11">HTTP/1.1: Semantics and Content, section 6.5.11</a> 234 */ 235 PAYLOAD_TOO_LARGE(413, "Payload Too Large"), 236 /** 237 * {@code 413 Request Entity Too Large}. 238 * @see <a href="https://tools.ietf.org/html/rfc2616#section-10.4.14">HTTP/1.1, section 10.4.14</a> 239 * @deprecated in favor of {@link #PAYLOAD_TOO_LARGE} which will be returned from {@code HttpStatus.valueOf(413)} 240 */ 241 @Deprecated 242 REQUEST_ENTITY_TOO_LARGE(413, "Request Entity Too Large"), 243 /** 244 * {@code 414 URI Too Long}. 245 * @since 4.1 246 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.12">HTTP/1.1: Semantics and Content, section 6.5.12</a> 247 */ 248 URI_TOO_LONG(414, "URI Too Long"), 249 /** 250 * {@code 414 Request-URI Too Long}. 251 * @see <a href="https://tools.ietf.org/html/rfc2616#section-10.4.15">HTTP/1.1, section 10.4.15</a> 252 * @deprecated in favor of {@link #URI_TOO_LONG} which will be returned from {@code HttpStatus.valueOf(414)} 253 */ 254 @Deprecated 255 REQUEST_URI_TOO_LONG(414, "Request-URI Too Long"), 256 /** 257 * {@code 415 Unsupported Media Type}. 258 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.13">HTTP/1.1: Semantics and Content, section 6.5.13</a> 259 */ 260 UNSUPPORTED_MEDIA_TYPE(415, "Unsupported Media Type"), 261 /** 262 * {@code 416 Requested Range Not Satisfiable}. 263 * @see <a href="https://tools.ietf.org/html/rfc7233#section-4.4">HTTP/1.1: Range Requests, section 4.4</a> 264 */ 265 REQUESTED_RANGE_NOT_SATISFIABLE(416, "Requested range not satisfiable"), 266 /** 267 * {@code 417 Expectation Failed}. 268 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.5.14">HTTP/1.1: Semantics and Content, section 6.5.14</a> 269 */ 270 EXPECTATION_FAILED(417, "Expectation Failed"), 271 /** 272 * {@code 418 I'm a teapot}. 273 * @see <a href="https://tools.ietf.org/html/rfc2324#section-2.3.2">HTCPCP/1.0</a> 274 */ 275 I_AM_A_TEAPOT(418, "I'm a teapot"), 276 /** 277 * @deprecated See <a href="https://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">WebDAV Draft Changes</a> 278 */ 279 @Deprecated 280 INSUFFICIENT_SPACE_ON_RESOURCE(419, "Insufficient Space On Resource"), 281 /** 282 * @deprecated See <a href="https://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">WebDAV Draft Changes</a> 283 */ 284 @Deprecated 285 METHOD_FAILURE(420, "Method Failure"), 286 /** 287 * @deprecated See <a href="https://tools.ietf.org/rfcdiff?difftype=--hwdiff&url2=draft-ietf-webdav-protocol-06.txt">WebDAV Draft Changes</a> 288 */ 289 @Deprecated 290 DESTINATION_LOCKED(421, "Destination Locked"), 291 /** 292 * {@code 422 Unprocessable Entity}. 293 * @see <a href="https://tools.ietf.org/html/rfc4918#section-11.2">WebDAV</a> 294 */ 295 UNPROCESSABLE_ENTITY(422, "Unprocessable Entity"), 296 /** 297 * {@code 423 Locked}. 298 * @see <a href="https://tools.ietf.org/html/rfc4918#section-11.3">WebDAV</a> 299 */ 300 LOCKED(423, "Locked"), 301 /** 302 * {@code 424 Failed Dependency}. 303 * @see <a href="https://tools.ietf.org/html/rfc4918#section-11.4">WebDAV</a> 304 */ 305 FAILED_DEPENDENCY(424, "Failed Dependency"), 306 /** 307 * {@code 426 Upgrade Required}. 308 * @see <a href="https://tools.ietf.org/html/rfc2817#section-6">Upgrading to TLS Within HTTP/1.1</a> 309 */ 310 UPGRADE_REQUIRED(426, "Upgrade Required"), 311 /** 312 * {@code 428 Precondition Required}. 313 * @see <a href="https://tools.ietf.org/html/rfc6585#section-3">Additional HTTP Status Codes</a> 314 */ 315 PRECONDITION_REQUIRED(428, "Precondition Required"), 316 /** 317 * {@code 429 Too Many Requests}. 318 * @see <a href="https://tools.ietf.org/html/rfc6585#section-4">Additional HTTP Status Codes</a> 319 */ 320 TOO_MANY_REQUESTS(429, "Too Many Requests"), 321 /** 322 * {@code 431 Request Header Fields Too Large}. 323 * @see <a href="https://tools.ietf.org/html/rfc6585#section-5">Additional HTTP Status Codes</a> 324 */ 325 REQUEST_HEADER_FIELDS_TOO_LARGE(431, "Request Header Fields Too Large"), 326 /** 327 * {@code 451 Unavailable For Legal Reasons}. 328 * @see <a href="https://tools.ietf.org/html/draft-ietf-httpbis-legally-restricted-status-04"> 329 * An HTTP Status Code to Report Legal Obstacles</a> 330 * @since 4.3 331 */ 332 UNAVAILABLE_FOR_LEGAL_REASONS(451, "Unavailable For Legal Reasons"), 333 334 // --- 5xx Server Error --- 335 336 /** 337 * {@code 500 Internal Server Error}. 338 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.6.1">HTTP/1.1: Semantics and Content, section 6.6.1</a> 339 */ 340 INTERNAL_SERVER_ERROR(500, "Internal Server Error"), 341 /** 342 * {@code 501 Not Implemented}. 343 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.6.2">HTTP/1.1: Semantics and Content, section 6.6.2</a> 344 */ 345 NOT_IMPLEMENTED(501, "Not Implemented"), 346 /** 347 * {@code 502 Bad Gateway}. 348 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.6.3">HTTP/1.1: Semantics and Content, section 6.6.3</a> 349 */ 350 BAD_GATEWAY(502, "Bad Gateway"), 351 /** 352 * {@code 503 Service Unavailable}. 353 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.6.4">HTTP/1.1: Semantics and Content, section 6.6.4</a> 354 */ 355 SERVICE_UNAVAILABLE(503, "Service Unavailable"), 356 /** 357 * {@code 504 Gateway Timeout}. 358 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.6.5">HTTP/1.1: Semantics and Content, section 6.6.5</a> 359 */ 360 GATEWAY_TIMEOUT(504, "Gateway Timeout"), 361 /** 362 * {@code 505 HTTP Version Not Supported}. 363 * @see <a href="https://tools.ietf.org/html/rfc7231#section-6.6.6">HTTP/1.1: Semantics and Content, section 6.6.6</a> 364 */ 365 HTTP_VERSION_NOT_SUPPORTED(505, "HTTP Version not supported"), 366 /** 367 * {@code 506 Variant Also Negotiates} 368 * @see <a href="https://tools.ietf.org/html/rfc2295#section-8.1">Transparent Content Negotiation</a> 369 */ 370 VARIANT_ALSO_NEGOTIATES(506, "Variant Also Negotiates"), 371 /** 372 * {@code 507 Insufficient Storage} 373 * @see <a href="https://tools.ietf.org/html/rfc4918#section-11.5">WebDAV</a> 374 */ 375 INSUFFICIENT_STORAGE(507, "Insufficient Storage"), 376 /** 377 * {@code 508 Loop Detected} 378 * @see <a href="https://tools.ietf.org/html/rfc5842#section-7.2">WebDAV Binding Extensions</a> 379 */ 380 LOOP_DETECTED(508, "Loop Detected"), 381 /** 382 * {@code 509 Bandwidth Limit Exceeded} 383 */ 384 BANDWIDTH_LIMIT_EXCEEDED(509, "Bandwidth Limit Exceeded"), 385 /** 386 * {@code 510 Not Extended} 387 * @see <a href="https://tools.ietf.org/html/rfc2774#section-7">HTTP Extension Framework</a> 388 */ 389 NOT_EXTENDED(510, "Not Extended"), 390 /** 391 * {@code 511 Network Authentication Required}. 392 * @see <a href="https://tools.ietf.org/html/rfc6585#section-6">Additional HTTP Status Codes</a> 393 */ 394 NETWORK_AUTHENTICATION_REQUIRED(511, "Network Authentication Required"); 395 396 397 private final int value; 398 399 private final String reasonPhrase; 400 401 402 HttpStatus(int value, String reasonPhrase) { 403 this.value = value; 404 this.reasonPhrase = reasonPhrase; 405 } 406 407 408 /** 409 * Return the integer value of this status code. 410 */ 411 public int value() { 412 return this.value; 413 } 414 415 /** 416 * Return the reason phrase of this status code. 417 */ 418 public String getReasonPhrase() { 419 return this.reasonPhrase; 420 } 421 422 /** 423 * Return the HTTP status series of this status code. 424 * @see HttpStatus.Series 425 */ 426 public Series series() { 427 return Series.valueOf(this); 428 } 429 430 /** 431 * Whether this status code is in the HTTP series 432 * {@link org.springframework.http.HttpStatus.Series#INFORMATIONAL}. 433 * This is a shortcut for checking the value of {@link #series()}. 434 * @since 4.0 435 * @see #series() 436 */ 437 public boolean is1xxInformational() { 438 return (series() == Series.INFORMATIONAL); 439 } 440 441 /** 442 * Whether this status code is in the HTTP series 443 * {@link org.springframework.http.HttpStatus.Series#SUCCESSFUL}. 444 * This is a shortcut for checking the value of {@link #series()}. 445 * @since 4.0 446 * @see #series() 447 */ 448 public boolean is2xxSuccessful() { 449 return (series() == Series.SUCCESSFUL); 450 } 451 452 /** 453 * Whether this status code is in the HTTP series 454 * {@link org.springframework.http.HttpStatus.Series#REDIRECTION}. 455 * This is a shortcut for checking the value of {@link #series()}. 456 * @since 4.0 457 * @see #series() 458 */ 459 public boolean is3xxRedirection() { 460 return (series() == Series.REDIRECTION); 461 } 462 463 /** 464 * Whether this status code is in the HTTP series 465 * {@link org.springframework.http.HttpStatus.Series#CLIENT_ERROR}. 466 * This is a shortcut for checking the value of {@link #series()}. 467 * @since 4.0 468 * @see #series() 469 */ 470 public boolean is4xxClientError() { 471 return (series() == Series.CLIENT_ERROR); 472 } 473 474 /** 475 * Whether this status code is in the HTTP series 476 * {@link org.springframework.http.HttpStatus.Series#SERVER_ERROR}. 477 * This is a shortcut for checking the value of {@link #series()}. 478 * @since 4.0 479 * @see #series() 480 */ 481 public boolean is5xxServerError() { 482 return (series() == Series.SERVER_ERROR); 483 } 484 485 /** 486 * Return a string representation of this status code. 487 */ 488 @Override 489 public String toString() { 490 return Integer.toString(this.value); 491 } 492 493 494 /** 495 * Return the enum constant of this type with the specified numeric value. 496 * @param statusCode the numeric value of the enum to be returned 497 * @return the enum constant with the specified numeric value 498 * @throws IllegalArgumentException if this enum has no constant for the specified numeric value 499 */ 500 public static HttpStatus valueOf(int statusCode) { 501 for (HttpStatus status : values()) { 502 if (status.value == statusCode) { 503 return status; 504 } 505 } 506 throw new IllegalArgumentException("No matching constant for [" + statusCode + "]"); 507 } 508 509 510 /** 511 * Enumeration of HTTP status series. 512 * <p>Retrievable via {@link HttpStatus#series()}. 513 */ 514 public enum Series { 515 516 INFORMATIONAL(1), 517 SUCCESSFUL(2), 518 REDIRECTION(3), 519 CLIENT_ERROR(4), 520 SERVER_ERROR(5); 521 522 private final int value; 523 524 Series(int value) { 525 this.value = value; 526 } 527 528 /** 529 * Return the integer value of this status series. Ranges from 1 to 5. 530 */ 531 public int value() { 532 return this.value; 533 } 534 535 /** 536 * Return the enum constant of this type with the corresponding series. 537 * @param status a standard HTTP status enum value 538 * @return the enum constant of this type with the corresponding series 539 * @throws IllegalArgumentException if this enum has no corresponding constant 540 */ 541 public static Series valueOf(HttpStatus status) { 542 return valueOf(status.value); 543 } 544 545 /** 546 * Return the enum constant of this type with the corresponding series. 547 * @param statusCode the HTTP status code (potentially non-standard) 548 * @return the enum constant of this type with the corresponding series 549 * @throws IllegalArgumentException if this enum has no corresponding constant 550 */ 551 public static Series valueOf(int statusCode) { 552 int seriesCode = statusCode / 100; 553 for (Series series : values()) { 554 if (series.value == seriesCode) { 555 return series; 556 } 557 } 558 throw new IllegalArgumentException("No matching constant for [" + statusCode + "]"); 559 } 560 } 561 562}