All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.eBus.client.EFeedState Maven / Gradle / Ivy

The newest version!
//
// Copyright 2015 Charles W. Rapp
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package net.sf.eBus.client;

/**
 * Enumerates an eBus notification message feed state: either up
 * or down.
 */

public enum EFeedState
{
    /**
     * The message feed state is unknown due to the feed just
     * being constructed.
     */
    UNKNOWN (0, 0, false),

    /**
     * The message feed is down. Subscribers will not receive
     * messages on this feed until informed that the feed is up.
     * Decrement feed counts when this is the state. If the feed
     * count reaches zero as a result of the decrement, send a
     * feed down status update.
     */
    DOWN (-1, 0, false),

    /**
     * The message feed is up. Subscribers may expect to receive
     * messages on this feed if and when any such
     * messages are published. Increment feed counts with this
     * state. If the feed count reaches one as a result of the
     * increment, send a feed up status update.
     */
    UP (1, 1, true);

//---------------------------------------------------------------
// Member data.
//

    //-----------------------------------------------------------
    // Locals.
    //

    /**
     * Increment feed counts by this value.
     */
    public final int increment;

    /**
     * After applying this feed state to a feed count, if the
     * feed count now equals this value, that triggers a feed
     * state update sent to the appropriate feeds.
     */
    public final int trigger;

    /**
     * {@code true} if the feed is up and {@code false} if down.
     */
    public final boolean flag;

//---------------------------------------------------------------
// Member methods.
//

    //-----------------------------------------------------------
    // Constructors.
    //

    private EFeedState(final int incr,
                       final int trigger,
                       final boolean flag)
    {
        this.increment = incr;
        this.trigger = trigger;
        this.flag = flag;
    } // end of EFeedState(int, int, boolean)

    //
    // end of Constructors.
    //-----------------------------------------------------------
} // end of enum EFeedState




© 2015 - 2024 Weber Informatics LLC | Privacy Policy