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

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

The newest version!
//
// Copyright 2012, 2013, 2016, 2019 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.sysmessages;

import java.io.Serializable;
import net.sf.eBus.messages.ESystemMessage;

/**
 * This message is sent to cancel an in-progress request running
 * on a remote eBus application. The cancel request is matched
 * to the remote proxy requestor based on either the
 * from proxy identifier or to proxy identifier.
 *
 * @author Charles Rapp
 */

public final class CancelRequest
    extends ESystemMessage
    implements Serializable
{
//---------------------------------------------------------------
// Member data.
//

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

    /**
     * Serialization version identifier.
     */
    private static final long serialVersionUID = 0x050200L;

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

    /**
     * If {@code true} then this is an optional cancel request,
     * allowing the replier to respond to the request, accepting
     * or rejecting the cancel request. If {@code false} then
     * this is a unilateral cancel request which the replier must
     * accept.
     */
    public final boolean mayRespond;

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

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

    private CancelRequest(final Builder builder)
    {
        super (builder);

        mayRespond = builder.mMayRespond;
    } // end of CancelRequest(Builder)

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

    /**
     * Returns a new instance of the {@code CancelMessage}
     * builder.
     * @return message builder instance.
     */
    public static Builder builder()
    {
        return (new Builder());
    } // end of builder()

//---------------------------------------------------------------
// Inner classes.
//

    public static final class Builder
        extends ESystemMessage.Builder
    {
    //-----------------------------------------------------------
    // Member data.
    //

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

        /**
         * "Replier may respond" flag. Defaults to {@code false}.
         */
        private boolean mMayRespond;

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

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

        private Builder()
        {
            super (CancelRequest.class);

            mMayRespond = false;
        } // end of Builder()

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

        //-------------------------------------------------------
        // Builder Method Overrides.
        //

        /**
         * Returns the newly instantiated {@code CancelMessage}
         * based on this builder configuration.
         * @return target message instance.
         */
        @Override
        protected CancelRequest buildImpl()
        {
            return (new CancelRequest(this));
        } // end of buildImpl()

        //
        // end of Builder Method Overrides.
        //-------------------------------------------------------

        //-------------------------------------------------------
        // Set Methods.
        //

        /**
         * Sets the "replier may respond" flag to the given
         * value. If {@code flag} is {@code true} then replier
         * may respond to cancel request, either accepting or
         * rejecting the cancellation. If {@code false} then this
         * is a unilateral cancellation and the replier must
         * accept the request as canceled.
         * @param flag replier may respond flag.
         * @return {@code this CancelRequest} builder.
         */
        public Builder mayRespond(final boolean flag)
        {
            mMayRespond = flag;

            return (this);
        } // end of mayRespond(boolean)

        //
        // end of Set Methods.
        //-------------------------------------------------------
    } // end of class Builder
} // end of class CancelRequest




© 2015 - 2024 Weber Informatics LLC | Privacy Policy