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,
<any> 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
Entity.SensorSupport.set(AttributeSensor, Object) , except does not publish an attribute-change event. |
public <T> T get(AttributeSensor<T> attribute)
Entity.SensorSupport
get
in interface Entity.SensorSupport
public <T> T set(AttributeSensor<T> attribute, T val)
Entity.SensorSupport
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.set
in interface Entity.SensorSupport
null
)public <T> T setWithoutPublishing(AttributeSensor<T> attribute, T val)
EntityInternal.SensorSupportInternal
Entity.SensorSupport.set(AttributeSensor, Object)
, except does not publish an attribute-change event.
Used for rebinding.setWithoutPublishing
in interface EntityInternal.SensorSupportInternal
public <T> T modify(AttributeSensor<T> attribute, <any> modifier)
Entity.SensorSupport
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).modify
in interface Entity.SensorSupport
null
)public void remove(AttributeSensor<?> attribute)
remove
in interface EntityInternal.SensorSupportInternal
public java.util.Map<AttributeSensor<?>,java.lang.Object> getAll()
getAll
in interface Entity.SensorSupport
public <T> void emit(Sensor<T> sensor, T val)
Entity.SensorSupport
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.
emit
in interface Entity.SensorSupport
public <T> void emitInternal(Sensor<T> sensor, T val)