net.sf.eBus.client.FeedStatusCallback Maven / Gradle / Ivy
The newest version!
//
// Copyright 2016 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;
/**
* An eBus client implementing either {@code ESubscriber},
* {@code EPublisher}, or {@code ERequestor} is not required
* to override the matching feed status method (
* {@link ESubscriber#feedStatus(EFeedState, IESubscribeFeed)},
* {@link EPublisher#publishStatus(EFeedState, IEPublishFeed)}, or
* {@link ERequestor#feedStatus(EFeedState, IERequestFeed)}).
* Instead, a lambda expression implementing this interface may
* be used as the callback. This allows for tighter coupling
* between the status callback and the code for handling the
* callback.
*
* Note: This must be done after opening a feed and before
* advertising or subscribing.
*
*
* @author Charles W. Rapp
*
* @param must be either {@link ERequestFeed},
* {@link ESubscribeFeed}, or {@link EPublishFeed}.
*
* @see EPublishFeed.Builder#statusCallback(FeedStatusCallback)
* @see ESubscribeFeed.Builder#statusCallback(FeedStatusCallback)
* @see ERequestFeed.Builder#statusCallback(FeedStatusCallback)
*/
@FunctionalInterface
public interface FeedStatusCallback
{
//---------------------------------------------------------------
// Member methods.
//
/**
* eBus calls this method to inform the eBus client that the
* feed is either
* {@link EFeedState#UP up} or {@link EFeedState#DOWN down}.
* @param feedState the subscription's new feed state.
* @param feed the status applies to this feed.
*/
void call(EFeedState feedState, T feed);
} // end of interface FeedStatusCallback