org.flexiblepower.observation.ext
T
- The type of the valuepublic abstract class AbstractObservationProvider<T> extends java.lang.Object implements ObservationProvider<T>
ObservationProvider
where the subscribe(ObservationConsumer)
and
unsubscribe(ObservationConsumer)
methods are implemented. To publish a new observation, the
publish(Observation)
method should be used.Constructor and Description |
---|
AbstractObservationProvider() |
Modifier and Type | Method and Description |
---|---|
Observation<? extends T> |
getLastObservation()
Get the last published
Observation . |
void |
publish(Observation<? extends T> observation)
Publishes an observation to all the subscribed consumers.
|
void |
subscribe(ObservationConsumer<? super T> consumer)
Binds the consumer to this provider.
|
void |
unsubscribe(ObservationConsumer<? super T> consumer)
Unbinds the consumer from this provider.
|
public void subscribe(ObservationConsumer<? super T> consumer)
ObservationProvider
ObservationConsumer.consume(ObservationProvider, Observation)
method.subscribe
in interface ObservationProvider<T>
consumer
- The ObservationConsumer
that will be bound to this provider.public void unsubscribe(ObservationConsumer<? super T> consumer)
ObservationProvider
unsubscribe
in interface ObservationProvider<T>
consumer
- The ObservationConsumer
that will be unbound from this provider.public Observation<? extends T> getLastObservation()
ObservationProvider
Observation
.getLastObservation
in interface ObservationProvider<T>
public void publish(Observation<? extends T> observation)
observation
- The observation that will be sent.