brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [6/7] brooklyn-server git commit: make lambdas/streams more accepting of other types
Date Sat, 16 Sep 2017 01:52:05 GMT
make lambdas/streams more accepting of other types


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/13c368ac
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/13c368ac
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/13c368ac

Branch: refs/heads/master
Commit: 13c368ac45f8c044ae6583670ccc2c59c0321947
Parents: 5be75f4
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Fri Sep 15 10:37:16 2017 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri Sep 15 10:37:16 2017 +0100

----------------------------------------------------------------------
 .../org/apache/brooklyn/core/objs/AbstractEntityAdjunct.java  | 5 +++--
 .../brooklyn/enricher/stock/TransformingEnricherTest.java     | 7 ++++---
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/13c368ac/core/src/main/java/org/apache/brooklyn/core/objs/AbstractEntityAdjunct.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/objs/AbstractEntityAdjunct.java b/core/src/main/java/org/apache/brooklyn/core/objs/AbstractEntityAdjunct.java
index 7ed58f0..2c4c4b4 100644
--- a/core/src/main/java/org/apache/brooklyn/core/objs/AbstractEntityAdjunct.java
+++ b/core/src/main/java/org/apache/brooklyn/core/objs/AbstractEntityAdjunct.java
@@ -55,6 +55,7 @@ import org.apache.brooklyn.core.entity.Entities;
 import org.apache.brooklyn.core.entity.EntityInternal;
 import org.apache.brooklyn.core.entity.internal.ConfigUtilsInternal;
 import org.apache.brooklyn.core.mgmt.internal.SubscriptionTracker;
+import org.apache.brooklyn.util.collections.MutableSet;
 import org.apache.brooklyn.util.core.config.ConfigBag;
 import org.apache.brooklyn.util.core.flags.FlagUtils;
 import org.apache.brooklyn.util.core.flags.SetFromFlag;
@@ -619,7 +620,7 @@ public abstract class AbstractEntityAdjunct extends AbstractBrooklynObject
imple
         if (sensors==null || Iterables.isEmpty(sensors)) {
             msg.append("<nothing>");
         } else {
-            String sensorsText = StreamSupport.stream(sensors.spliterator(), false)
+            String sensorsText = MutableSet.<Object>copyOf(sensors).stream()
                     .filter(s -> s != null)
                     .map(s -> (s instanceof Sensor ? ((Sensor<?>) s).getName() :
s.toString()))
                     .collect(Collectors.joining(", "));
@@ -627,7 +628,7 @@ public abstract class AbstractEntityAdjunct extends AbstractBrooklynObject
imple
         }
 
         if (sources!=null && !Iterables.isEmpty(sources)) {
-            String sourcesText = StreamSupport.stream(sources.spliterator(), false)
+            String sourcesText = MutableSet.<Object>copyOf(sources).stream()
                     .filter(s -> s != null)
                     .map(s -> (s.equals(getEntity()) ? "self" : s.toString()))
                     .collect(Collectors.joining(", "));

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/13c368ac/core/src/test/java/org/apache/brooklyn/enricher/stock/TransformingEnricherTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/enricher/stock/TransformingEnricherTest.java
b/core/src/test/java/org/apache/brooklyn/enricher/stock/TransformingEnricherTest.java
index 1be9a36..b38bd92 100644
--- a/core/src/test/java/org/apache/brooklyn/enricher/stock/TransformingEnricherTest.java
+++ b/core/src/test/java/org/apache/brooklyn/enricher/stock/TransformingEnricherTest.java
@@ -75,9 +75,10 @@ public class TransformingEnricherTest extends BrooklynAppUnitTestSupport
{
 
         producer.enrichers().add(Enrichers.builder()
                 .transforming(intSensorA)
-                //.computing(MathFunctions.times(2)) // TODO calling it before "publishing"
means it doesn't check return type!
+                .computing(MathFunctions.times(2))
                 .publishing(target)
-                .computing((Function)MathFunctions.times(2)) // TODO doesn't match strongly
typed int->long
+                // note: if `computing` comes later, we lose some type inference, have to
give explicit types or go unchecked
+                //.computing((Function)MathFunctions.times(2))
                 .build());
 
         EntityAsserts.assertAttributeEqualsEventually(producer, target, 6L);
@@ -157,7 +158,7 @@ public class TransformingEnricherTest extends BrooklynAppUnitTestSupport
{
         // Doing nasty casting here, but in YAML we could easily get passed this.
         producer.enrichers().add(EnricherSpec.create(Transformer.class)
                 .configure(Transformer.TARGET_SENSOR, target)
-                .configure(Transformer.TRIGGER_SENSORS, (List<Sensor<?>>)(List)ImmutableList.of(intSensorA.getName(),
intSensorB.getName()))
+                .configure(Transformer.TRIGGER_SENSORS, (List<Sensor<?>>)(List<?>)ImmutableList.of(intSensorA.getName(),
intSensorB.getName()))
                 .configure(Transformer.PRODUCER, producer)
                 .configure(Transformer.TARGET_VALUE, new DeferredSupplier<Long>() {
                     @Override public Long get() {


Mime
View raw message