public <T> Map<Entity,T> getValues(Sensor<T> sensor) { Map<Entity, T> valuesCopy = copyValues(sensor); return coerceValues(valuesCopy, sensor.getType()); }
@SuppressWarnings("unchecked") private U resolveImmediately(Object rawVal, Sensor<U> targetSensor) { if (rawVal == Entities.UNCHANGED || rawVal == Entities.REMOVE) { // If it's a special marker-object, then don't try to transform it return (U) rawVal; } // evaluate immediately, or return null. // For vals that implement ImmediateSupplier, we'll use that to get the value // (or Maybe.absent) without blocking. // Otherwise, the Tasks.resolving will give it its best shot at resolving without // blocking on external events (such as waiting for another entity's sensor). return (U) Tasks.resolving(rawVal).as(targetSensor.getType()) .context(entity) .description("Computing sensor "+targetSensor+" from "+rawVal) .immediately(true) .getMaybe().orNull(); } }