T
- The expected broadcastable type.public final class TypeInterestBroadcaster<T> extends AbstractBroadcaster implements InterestBroadcaster<T>
InterestBroadcaster
that is interested in all broadcasts of a particular type.
This is similar to QueryableBroadcaster
except this only collects instances a single type, and as such should be
preferred when possible.
next
Constructor and Description |
---|
TypeInterestBroadcaster(Class<T> klass)
Creates a new
TypeInterestBroadcaster . |
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
TypeInterestBroadcaster instance. |
Optional<T> |
one()
Gets the first or only unit of the expected type to be broadcast, if present.
|
InterestBroadcaster<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 TypeInterestBroadcaster(Class<T> klass)
TypeInterestBroadcaster
.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>
Optional
if not present.public Iterable<T> gather()
InterestBroadcaster
gather
in interface InterestBroadcaster<T>
public InterestBroadcaster<T> reset()
InterestBroadcaster
reset
in interface InterestBroadcaster<T>
public static <T extends Broadcastable> TypeInterestBroadcaster<T> of(Class<T> klass)
TypeInterestBroadcaster
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.