Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/131#discussion_r16923469
--- Diff: core/src/main/java/brooklyn/enricher/Enrichers.java ---
@@ -443,41 +518,106 @@ public String toString() {
}
}
- private static class ConcreteInitialBuilder extends
InitialBuilder<ConcreteInitialBuilder> {
+ public abstract static class AbstractUpdatingMapBuilder<S, TKey, TVal,
B extends AbstractUpdatingMapBuilder<S, TKey, TVal, B>> extends
AbstractEnricherBuilder<B> {
+ protected AttributeSensor<Map<TKey,TVal>> targetSensor;
+ protected AttributeSensor<? extends S> fromSensor;
+ protected TKey key;
+ protected Function<S, ? extends TVal> computing;
+ protected Boolean removingIfResultIsNull;
+
+ public AbstractUpdatingMapBuilder(AttributeSensor<Map<TKey,TVal>>
target) {
+ super(UpdatingMap.class);
+ this.targetSensor = target;
+ }
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public <S2 extends S> UpdatingMapBuilder<S2,TKey,TVal>
from(AttributeSensor<S2> fromSensor) {
--- End diff --
see e.g. `EnrichersTest.testUpdatingMap1()`. this cheats generics to
return an appropriately further-genericised builder. assuming `S` is was not
specified it is `Object` after the compiler hits the static method. without
the cast to `S2` generic type the builder would want a function returning
`Object`. *with* this cast if we give a `Sensor<String>` the other method
calls are further constrainged to need to be e.g. `computing` a `String`. HTH.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---