@Override protected <T> void emit(Sensor<T> sensor, Object val) { checkState(entity != null, "entity must first be set"); if (val == Entities.UNCHANGED) { return; } if (val == Entities.REMOVE) { ((EntityInternal)entity).sensors().remove((AttributeSensor<T>) sensor); return; } T newVal = TypeCoercions.coerce(val, sensor.getTypeToken()); Maybe<T> published = Maybe.of(newVal); if (sensor instanceof AttributeSensor) { AttributeSensor<T> attribute = (AttributeSensor<T>)sensor; if (Boolean.TRUE.equals(suppressDuplicates)) { DeduplicatingAttributeModifier<T> modifier = DeduplicatingAttributeModifier.create(newVal); entity.sensors().modify(attribute, modifier); published = modifier.getLastValue(); } else { entity.sensors().set(attribute, newVal); } } else { entity.sensors().emit(sensor, newVal); } if (published!=null && published.isPresent()) { highlightActionPublishSensor(sensor, published.get()); } }
entity.sensors().modify(sensor, modifier);