@Beta
public static interface Entity.SensorSupport
Modifier and Type | Method and Description |
---|---|
<T> void |
emit(Sensor<T> sensor,
T value)
Emits a
SensorEvent event on behalf of this entity (as though produced by this entity). |
<T> T |
get(AttributeSensor<T> key)
Gets the value of the given attribute on this entity, or null if has not been set.
|
<T> T |
modify(AttributeSensor<T> attribute,
com.google.common.base.Function<? super T,Maybe<T>> modifier)
Atomically modifies the
AttributeSensor , ensuring that only one modification is done
at a time. |
<T> T |
set(AttributeSensor<T> attribute,
T val)
Sets the
AttributeSensor data for the given attribute to the specified value. |
<T> T get(AttributeSensor<T> key)
<T> T set(AttributeSensor<T> attribute, T val)
AttributeSensor
data for the given attribute to the specified value.
This can be used to "enrich" the entity, such as adding aggregated information,
rolling averages, etc.null
)@Beta <T> T modify(AttributeSensor<T> attribute, com.google.common.base.Function<? super T,Maybe<T>> modifier)
AttributeSensor
, ensuring that only one modification is done
at a time.
If the modifier returns Maybe.absent()
then the attribute will be
left unmodified, and the existing value will be returned.
For details of the synchronization model used to achieve this, refer to the underlying
attribute store (e.g. AttributeMap).null
)<T> void emit(Sensor<T> sensor, T value)
SensorEvent
event on behalf of this entity (as though produced by this entity).
Note that for attribute sensors it is nearly always recommended to use setAttribute, as this method will not update local values.