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

net.sf.eBus.client.sysmessages.FeedStatusMessage Maven / Gradle / Ivy

//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later
// version.
//
// This library is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General
// Public License along with this library; if not, write to the
//
// Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330,
// Boston, MA
// 02111-1307 USA
//
// The Initial Developer of the Original Code is Charles W. Rapp.
// Portions created by Charles W. Rapp are
// Copyright 2012, 2013, 2016. Charles W. Rapp
// All Rights Reserved.
//

package net.sf.eBus.client.sysmessages;

import java.io.Serializable;
import net.sf.eBus.client.EFeedState;
import net.sf.eBus.messages.EFieldInfo;
import net.sf.eBus.messages.ESystemMessage;

/**
 * Forwards a notification feed status to a remote eBus
 * application so it can be reported to the remote subscribers.
 *
 * @author Charles Rapp
 */

@EFieldInfo(fields={"feedState"})
public final class FeedStatusMessage
    extends ESystemMessage
    implements Serializable
{
//---------------------------------------------------------------
// Member methods.
//

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

    /**
     * Creates a new feed status message for the given feed state
     * and reason. The subject and timestamp are set to the
     * {@link ESystemMessage} defaults.
     * @param state feed state is either up or down.
     */
    public FeedStatusMessage(final EFeedState state)
    {
        super ();

        this.feedState = state;
    } // end of FeedStatusMessage(EFeedState)

    /**
     * Creates a new FeedStatus instance with the given
     * notification message identifier.
     * @param subject {@link ESystemMessage#SYSTEM_SUBJECT}.
     * @param timestamp message timestamp.
     * @param state feed state is either up or down.
     * @throws IllegalArgumentException
     * if {@code subject} is either {@code null} or empty.
     */
    public FeedStatusMessage(final String subject,
                             final long timestamp,
                             final EFeedState state)
        throws IllegalArgumentException
    {
        super (subject, timestamp);

        this.feedState = state;
    } // end of FeedStatusMessage(String, long, EFeedState)

    //
    // end of Constructors.
    //-----------------------------------------------------------

    //-----------------------------------------------------------
    // Object Method Overrides.
    //

    /**
     * Returns {@code true} if {@code o} is a
     * non-{@code null FeedStatusMessage} instance with feed
     * status and reason equal to {@code this FeedStatusMessage}
     * instance and {@code false} otherwise.
     * @param o comparison object.
     * @return {@code true} if the message fields are equal
     * and {@code false} otherwise.
     */
    @Override
    public boolean equals(final Object o)
    {
        boolean retcode = (this == o);

        if (retcode == false && o instanceof FeedStatusMessage)
        {
            final FeedStatusMessage fs = (FeedStatusMessage) o;

            retcode = (super.equals(o) == true &&
                       feedState == fs.feedState);
        }

        return (retcode);
    } // end of equals(Object)

    /**
     * Returns the feed status message hash code.
     * @return the feed status message hash code.
     */
    @Override
    public int hashCode()
    {
        return (((super.hashCode() * 37) + feedState.ordinal()));
    } // end of hashCode()

    /**
     * Returns a human-readable text version of this message.
     * @return text version of this message.
     */
    @Override
    public String toString()
    {
        return (
            String.format(
                "%s%n             feed state: %s",
                super.toString(),
                feedState));
    } // end of toString()

    //
    // end of Object Method Overrides.
    //-----------------------------------------------------------

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

    /**
     * The updated feed state.
     */
    public final EFeedState feedState;

    //-----------------------------------------------------------
    // Constants.
    //

    /**
     * Serialization version identifier.
     */
    private static final long serialVersionUID = 0x060100L;
} // end of class FeedStatus




© 2015 - 2025 Weber Informatics LLC | Privacy Policy