[ 
https://issues.apache.org/jira/browse/HTTPCORE-620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17005328#comment-17005328
 ] 

Gary D. Gregory commented on HTTPCORE-620:
------------------------------------------

There is existing logic where states are compared, in what looks like "is this 
state before that one" kind of logic.  Since it is a no-no to use an enum's 
ordinal value for this purpose, I refactored the int values as a rank field. 
This could probably be better abstracted without making the rank field public 
but I wanted a simple port at first.

We can revisit later if we want to add methods like 
Status#isBefore(Status)/Status#isAfter(Status) but I am not sure how much that 
would improve readability.

> Refactor int constants from org.apache.hc.core5.reactor.IOSession into an enum
> ------------------------------------------------------------------------------
>
>                 Key: HTTPCORE-620
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-620
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore
>            Reporter: Gary D. Gregory
>            Priority: Major
>
> Refactor int constants from {{org.apache.hc.core5.reactor.IOSession}} into an 
> enum called state:
>  * {color:#500050}int 
> org.apache.hc.core5.reactor.IO{color}{color:#500050}Session.ACTIVE{color}
>  * {color:#500050}int 
> org.apache.hc.core5.reactor.IO{color}{color:#500050}Session.CLOSED{color}
>  * {color:#500050}int 
> org.apache.hc.core5.reactor.IO{color}{color:#500050}Session.CLOSING{color}
> Like:
> {code:java}
> public interface IOSession extends ByteChannel, SocketModalCloseable, 
> Identifiable {
>     public enum Status {
>         ACTIVE(0),
>         CLOSING(1),
>         CLOSED(Integer.MAX_VALUE);
>         private Status(final int rank) {
>             this.rank = rank;
>         }
>         public final int rank;
>     }
> ...
> {code}
> PR coming...



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to