T
- The expected broadcastable type.public final class SingleInterestBroadcaster<T extends Broadcastable> extends AbstractBroadcaster implements InterestBroadcaster<T>
InterestBroadcaster
that is interested in only a single broadcast of a particular type.
Any broadcasts that do not match the expected type will be ignored, and only the first broadcast of the desired type will be stored. All broadcasts, matching or not, will still be passed along broadcast chain if applicable.
next
Constructor and Description |
---|
SingleInterestBroadcaster(Class<T> klass)
Creates a new
SingleInterestBroadcaster . |
Modifier and Type | Method and Description |
---|---|
void |
broadcast(Broadcastable broadcastable)
Broadcasts the given event (syntax unit).
|
Iterable<T> |
gather()
Gets all units of the expected type that were broadcasted.
|
static <T extends Broadcastable> |
of(Class<T> klass)
Convenience method to create a new
SingleInterestBroadcaster instance. |
Optional<T> |
one()
Gets the first or only unit of the expected type to be broadcast, if present.
|
SingleInterestBroadcaster<T> |
reset()
Clears all stored units that matched the expected type.
|
chain, chainBroadcast, cut, relay
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
chain, chainBroadcast, cut
public SingleInterestBroadcaster(Class<T> klass)
SingleInterestBroadcaster
.klass
- Class of the expected broadcastable.public void broadcast(Broadcastable broadcastable)
Broadcaster
broadcast
in interface Broadcaster
broadcastable
- The Broadcastable
syntax unit.public Optional<T> one()
InterestBroadcaster
one
in interface InterestBroadcaster<T extends Broadcastable>
Optional
if not present.public Iterable<T> gather()
InterestBroadcaster
gather
in interface InterestBroadcaster<T extends Broadcastable>
public SingleInterestBroadcaster<T> reset()
InterestBroadcaster
reset
in interface InterestBroadcaster<T extends Broadcastable>
public static <T extends Broadcastable> SingleInterestBroadcaster<T> of(Class<T> klass)
SingleInterestBroadcaster
instance.T
- The expected broadcastable type.klass
- Class of the expected broadcastable.Copyright (c) 2019, Salesforce.com, Inc. All rights reserved. Licensed under the BSD 3-Clause license. For full license text, see the LICENSE file in the repository.