de.team33.patterns.notes.eris.Channel Maven / Gradle / Ivy
package de.team33.patterns.notes.eris;
import java.util.function.Consumer;
/**
* Identifies channels of notifications and associates specific sorts of events with resulting message types.
* A typical application scenario might look something like this:
*
* In the context of a service or similar, events can occur about which interested participants may need to be
* notified. For example, a property of the service may change. A {@link Channel} is defined for each relevant
* event type in the context of the service and in this way the event type is linked to a message type.
* Last but not least, the service is the origin of the messages to be sent. Each channel "knows" how the
* service will deliver the message to be transmitted. Example:
*
* public class SampleService {
*
* private Path path;
* private Instant timestamp;
*
* // ...
*
* public interface Channel<M> extends de.team33.patterns.notes.eris.Channel<M>, Function<SampleService, M> {
*
* Channel<Path> NEW_PATH = service -> service.path;
* Channel<Instant> NEW_TIMESTAMP = service -> service.timestamp;
* Channel<SampleService> UPDATED = service -> service;
* }
* }
*
* This example defines a context-specific derivation of {@link Channel} that also "knows" a method to get a
* corresponding message from the service.
* In principle, this is not necessary, but it simplifies the structuring and formulation of the individual constants.
*
* @see Registry#add(Channel, Consumer) Registry.add(Channel<M>, Consumer<? super M>)
* @see Audience#send(Channel, Object) Audience.send(Channel<M>, M)
* @see Registry#add(Channel, Consumer)
* @see Audience#send(Channel, Object)
*
* @param The message type.
*/
public interface Channel {
}