/** @deprecated since 0.7.0 only {@link AbstractEnricher} has emit convenience */ 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).removeAttribute((AttributeSensor<T>) sensor); return; } T newVal = TypeCoercions.coerce(val, sensor.getTypeToken()); if (sensor instanceof AttributeSensor) { entity.sensors().set((AttributeSensor<T>) sensor, newVal); } else { entity.sensors().emit(sensor, newVal); } }
private <T> T resolve(ConfigKey<T> key, Object value) { Object transformed = transform(key, value); Object result; if (transformed instanceof DeferredSupplier) { ExecutionContext exec = mgmt.getServerExecutionContext(); try { result = Tasks.resolveValue(transformed, key.getType(), exec); } catch (ExecutionException | InterruptedException e) { throw Exceptions.propagate(e); } } else { result = transformed; } return TypeCoercions.coerce(result, key.getTypeToken()); }
public AbstractEntityAdjunct(@SuppressWarnings("rawtypes") Map properties) { super(properties); _legacyNoConstructionInit = (properties != null) && Boolean.TRUE.equals(properties.get("noConstructionInit")); if (isLegacyConstruction()) { AbstractBrooklynObject checkWeGetThis = configure(properties); assert this.equals(checkWeGetThis) : this + " configure method does not return itself; returns " + checkWeGetThis + " instead of " + this; boolean deferConstructionChecks = (properties.containsKey("deferConstructionChecks") && TypeCoercions.coerce(properties.get("deferConstructionChecks"), Boolean.class)); if (!deferConstructionChecks) { FlagUtils.checkRequiredFields(this); } } }