curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cammckenzie <...@git.apache.org>
Subject [GitHub] curator pull request: Curator 110
Date Tue, 03 Jun 2014 23:35:38 GMT
Github user cammckenzie commented on a diff in the pull request:

    https://github.com/apache/curator/pull/9#discussion_r13365128
  
    --- Diff: curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java
---
    @@ -57,5 +57,15 @@
          * <a href="http://wiki.apache.org/hadoop/ZooKeeper/GSoCReadOnlyMode">http://wiki.apache.org/hadoop/ZooKeeper/GSoCReadOnlyMode</a>.
          * The connection will remain in read only mode until another state change is sent.
          */
    -    READ_ONLY
    +    READ_ONLY;
    +    
    +    /**
    +     * Check if this state indicates that Curator has a connection to ZooKeeper
    +     * 
    +     * @return True if connected, false otherwise
    +     */
    +    public boolean isConnected()
    +    {
    +        return this == CONNECTED || this == RECONNECTED || this == READ_ONLY;
    --- End diff --
    
    There you go, you learn something new everyday! I knew that enums could
    implement interfaces, and that they themselves couldn't be abstract but I
    didn't realise you could still put abstract methods on them.
    
    As far as an isDisconnected() method goes, you're happy with this just
    being defined as !isConnected()?
    
    
    On Wed, Jun 4, 2014 at 9:31 AM, Jordan Zimmerman <notifications@github.com>
    wrote:
    
    > In
    > curator-framework/src/main/java/org/apache/curator/framework/state/ConnectionState.java:
    >
    > > @@ -57,5 +57,15 @@
    > >       * <a href="http://wiki.apache.org/hadoop/ZooKeeper/GSoCReadOnlyMode">http://wiki.apache.org/hadoop/ZooKeeper/GSoCReadOnlyMode</a>.
    > >       * The connection will remain in read only mode until another state change
is sent.
    > >       */
    > > -    READ_ONLY
    > > +    READ_ONLY;
    > > +
    > > +    /**
    > > +     * Check if this state indicates that Curator has a connection to ZooKeeper
    > > +     *
    > > +     * @return True if connected, false otherwise
    > > +     */
    > > +    public boolean isConnected()
    > > +    {
    > > +        return this == CONNECTED || this == RECONNECTED || this == READ_ONLY;
    >
    > isConnected can be abstract:
    >
    > abstract public boolean isConnected();
    >
    > Then each enum value will implement it. It's cleaner and puts the
    > isConnected value close to the enum itself. Also, if we ever add new values
    > it forces us to implement isConnected.
    >
    > —
    > Reply to this email directly or view it on GitHub
    > <https://github.com/apache/curator/pull/9/files#r13364993>.
    >


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message