Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/141#discussion_r63969965
  
    --- Diff: 
core/src/main/java/org/apache/brooklyn/enricher/stock/AbstractTransformer.java 
---
    @@ -59,27 +72,55 @@ public void setEntity(EntityLocal entity) {
             super.setEntity(entity);
     
             this.producer = getConfig(PRODUCER) == null ? entity: 
getConfig(PRODUCER);
    -        this.sourceSensor = (Sensor<T>) getRequiredConfig(SOURCE_SENSOR);
    +        this.sourceSensor = (Sensor<T>) getConfig(SOURCE_SENSOR);
             Sensor<?> targetSensorSpecified = getConfig(TARGET_SENSOR);
    +        List<? extends Sensor<?>> triggerSensorsSpecified = 
getConfig(TRIGGER_SENSORS);
    +        List<? extends Sensor<?>> triggerSensors = triggerSensorsSpecified 
!= null ? triggerSensorsSpecified : ImmutableList.<Sensor<?>>of();
             this.targetSensor = targetSensorSpecified!=null ? (Sensor<U>) 
targetSensorSpecified : (Sensor<U>) this.sourceSensor;
    -        if (producer.equals(entity) && targetSensorSpecified==null) {
    +        if (targetSensor == null) {
    +            throw new IllegalArgumentException("Enricher 
"+JavaClassNames.simpleClassName(this)+" has no "+TARGET_SENSOR.getName()+", 
and it cannot be inferred as "+SOURCE_SENSOR.getName()+" is also not set");
    +        }
    +        if (sourceSensor == null && triggerSensors.isEmpty()) {
    +            throw new IllegalArgumentException("Enricher 
"+JavaClassNames.simpleClassName(this)+" has no "+SOURCE_SENSOR.getName()+" and 
no "+TRIGGER_SENSORS.getName());
    +        }
    --- End diff --
    
    You could use triggerSensors in combination with sourceSensor, as an 
additional way of it recalculating a value from the sourceSensor. Not quite 
sure when you'd want to do that but it should work!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to