You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by GitBox <gi...@apache.org> on 2020/12/14 22:14:37 UTC

[GitHub] [httpcomponents-core] garydgregory commented on a change in pull request #237: Add shorthand methods for the various status classes in StatusLine

garydgregory commented on a change in pull request #237:
URL: https://github.com/apache/httpcomponents-core/pull/237#discussion_r542859213



##########
File path: httpcore5/src/main/java/org/apache/hc/core5/http/message/StatusLine.java
##########
@@ -100,6 +99,61 @@ public StatusClass getStatusClass() {
         return this.statusClass;
     }
 
+    /**
+     * Whether this status code is in the HTTP series {@link StatusClass#INFORMATIONAL}.
+     *
+     * @since 5.1
+     */
+    public boolean isInformational() {
+        return getStatusClass() == StatusClass.INFORMATIONAL;
+    }
+
+    /**
+     * Whether this status code is in the HTTP series {@link StatusClass#SUCCESSFUL}.
+     *
+     * @since 5.1
+     */
+    public boolean isSuccessful() {
+        return getStatusClass() == StatusClass.SUCCESSFUL;
+    }
+
+    /**
+     * Whether this status code is in the HTTP series {@link StatusClass#REDIRECTION}.
+     *
+     * @since 5.1
+     */
+    public boolean isRedirection() {
+        return getStatusClass() == StatusClass.REDIRECTION;
+    }
+
+    /**
+     * Whether this status code is in the HTTP series {@link StatusClass#CLIENT_ERROR}.
+     *
+     * @since 5.1
+     */
+    public boolean isClientError() {
+        return getStatusClass() == StatusClass.CLIENT_ERROR;
+    }
+
+    /**
+     * Whether this status code is in the HTTP series {@link StatusClass#SERVER_ERROR}.
+     *
+     * @since 5.1
+     */
+    public boolean isServerError() {
+        return getStatusClass() == StatusClass.SERVER_ERROR;
+    }
+
+    /**
+     * Whether this status code is in the HTTP series {@link StatusClass#CLIENT_ERROR}
+     * or {@link StatusClass#SERVER_ERROR}.
+     *
+     * @since 5.1
+     */
+    public boolean isError() {
+        return (isClientError() || isServerError());

Review comment:
       These extra parents are not needed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org