storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bo...@apache.org
Subject [2/4] storm git commit: allow for boolean arguments;
Date Fri, 06 Nov 2015 20:52:02 GMT
allow for boolean arguments;


Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/76d73e97
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/76d73e97
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/76d73e97

Branch: refs/heads/master
Commit: 76d73e977f4fddcbf415d51980c9f9bbcd26e0db
Parents: d59eaac
Author: Chuck Burgess <cburgess@progressrail.com>
Authored: Thu Oct 29 16:44:28 2015 -0500
Committer: Chuck Burgess <cburgess@progressrail.com>
Committed: Fri Nov 6 10:00:01 2015 -0600

----------------------------------------------------------------------
 .../main/java/org/apache/storm/flux/FluxBuilder.java   | 13 +++++++++++++
 .../test/java/org/apache/storm/flux/test/TestBolt.java |  4 ++++
 .../test/resources/configs/config-methods-test.yaml    |  1 +
 3 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/storm/blob/76d73e97/external/flux/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java
----------------------------------------------------------------------
diff --git a/external/flux/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java
b/external/flux/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java
index 9f15e6b..f7c2575 100644
--- a/external/flux/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java
+++ b/external/flux/flux-core/src/main/java/org/apache/storm/flux/FluxBuilder.java
@@ -492,6 +492,12 @@ public class FluxBuilder {
                 constructorParams[i] = args.get(i);
                 continue;
             }
+            if (isPrimitiveBoolean(paramType) && Boolean.class.isAssignableFrom(objectType)){
+                LOG.debug("Its a primitive boolean.");
+                Boolean bool = (Boolean)args.get(i);
+                constructorParams[i] = bool.booleanValue();
+                continue;
+            }
             if(isPrimitiveNumber(paramType) && Number.class.isAssignableFrom(objectType)){
                 LOG.debug("Its a primitive number.");
                 Number num = (Number)args.get(i);
@@ -569,6 +575,9 @@ public class FluxBuilder {
                 LOG.debug("Yes, assignment is possible.");
                 return true;
             }
+            if (isPrimitiveBoolean(paramType) && Boolean.class.isAssignableFrom(objectType)){
+                return true;
+            }
             if(isPrimitiveNumber(paramType) && Number.class.isAssignableFrom(objectType)){
                 return true;
             }
@@ -591,5 +600,9 @@ public class FluxBuilder {
     public static boolean isPrimitiveNumber(Class clazz){
         return clazz.isPrimitive() && !clazz.equals(boolean.class);
     }
+
+    public static boolean isPrimitiveBoolean(Class clazz){
+        return clazz.isPrimitive() && clazz.equals(boolean.class);
+    }
 }
 

http://git-wip-us.apache.org/repos/asf/storm/blob/76d73e97/external/flux/flux-core/src/test/java/org/apache/storm/flux/test/TestBolt.java
----------------------------------------------------------------------
diff --git a/external/flux/flux-core/src/test/java/org/apache/storm/flux/test/TestBolt.java
b/external/flux/flux-core/src/test/java/org/apache/storm/flux/test/TestBolt.java
index 7f11460..40fa841 100644
--- a/external/flux/flux-core/src/test/java/org/apache/storm/flux/test/TestBolt.java
+++ b/external/flux/flux-core/src/test/java/org/apache/storm/flux/test/TestBolt.java
@@ -45,6 +45,10 @@ public class TestBolt extends BaseBasicBolt {
 
     }
 
+    public TestBolt(TestEnum te, float f, boolean b){
+
+    }
+
     @Override
     public void execute(Tuple tuple, BasicOutputCollector basicOutputCollector) {
         LOG.info("{}", tuple);

http://git-wip-us.apache.org/repos/asf/storm/blob/76d73e97/external/flux/flux-core/src/test/resources/configs/config-methods-test.yaml
----------------------------------------------------------------------
diff --git a/external/flux/flux-core/src/test/resources/configs/config-methods-test.yaml b/external/flux/flux-core/src/test/resources/configs/config-methods-test.yaml
index 65211ff..5563193 100644
--- a/external/flux/flux-core/src/test/resources/configs/config-methods-test.yaml
+++ b/external/flux/flux-core/src/test/resources/configs/config-methods-test.yaml
@@ -36,6 +36,7 @@ bolts:
     constructorArgs:
       - FOO # enum class
       - 1.0
+      - true
     configMethods:
       - name: "withFoo"
         args:


Mime
View raw message