@Beta public class AbstractEntity.BasicSensorSupport extends java.lang.Object implements EntityInternal.SensorSupportInternal
Entity.sensors() is reverted to return SensorSupport instead of
AbstractEntity.BasicSensorSupport.| Constructor and Description |
|---|
BasicSensorSupport() |
| Modifier and Type | Method and Description |
|---|---|
<T> void |
emit(Sensor<T> sensor,
T val)
Emits a
SensorEvent event on behalf of this entity (as though produced by this entity). |
<T> void |
emitInternal(Sensor<T> sensor,
T val) |
<T> T |
get(AttributeSensor<T> attribute)
Gets the value of the given attribute on this entity, or null if has not been set.
|
java.util.Map<AttributeSensor<?>,java.lang.Object> |
getAll() |
<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. |
void |
remove(AttributeSensor<?> attribute) |
<T> T |
set(AttributeSensor<T> attribute,
T val)
Sets the
AttributeSensor data for the given attribute to the specified value. |
<T> T |
setWithoutPublishing(AttributeSensor<T> attribute,
T val)
Like
EntityLocal.setAttribute(AttributeSensor, Object), except does not publish an attribute-change event. |
public <T> T get(AttributeSensor<T> attribute)
Entity.SensorSupportget in interface Entity.SensorSupportpublic <T> T set(AttributeSensor<T> attribute, T val)
Entity.SensorSupportAttributeSensor 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.set in interface Entity.SensorSupportnull)public <T> T setWithoutPublishing(AttributeSensor<T> attribute, T val)
EntityInternal.SensorSupportInternalEntityLocal.setAttribute(AttributeSensor, Object), except does not publish an attribute-change event.setWithoutPublishing in interface EntityInternal.SensorSupportInternal@Beta public <T> T modify(AttributeSensor<T> attribute, com.google.common.base.Function<? super T,Maybe<T>> modifier)
Entity.SensorSupportAttributeSensor, 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).modify in interface Entity.SensorSupportnull)public void remove(AttributeSensor<?> attribute)
remove in interface EntityInternal.SensorSupportInternalpublic java.util.Map<AttributeSensor<?>,java.lang.Object> getAll()
getAll in interface EntityInternal.SensorSupportInternalpublic <T> void emit(Sensor<T> sensor, T val)
Entity.SensorSupportSensorEvent 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.
emit in interface Entity.SensorSupportpublic <T> void emitInternal(Sensor<T> sensor, T val)