You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/09/02 15:18:54 UTC

[GitHub] zonghaishang closed pull request #2399: if to switch case

zonghaishang closed pull request #2399: if to switch case
URL: https://github.com/apache/incubator-dubbo/pull/2399
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/compiler/support/ClassUtils.java b/dubbo-common/src/main/java/org/apache/dubbo/common/compiler/support/ClassUtils.java
index 3d5235d63a..40c050f79e 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/compiler/support/ClassUtils.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/compiler/support/ClassUtils.java
@@ -79,38 +79,40 @@ public static Object newInstance(String name) {
     }
 
     public static Class<?> _forName(String className) throws ClassNotFoundException {
-        if ("boolean".equals(className))
-            return boolean.class;
-        if ("byte".equals(className))
-            return byte.class;
-        if ("char".equals(className))
-            return char.class;
-        if ("short".equals(className))
-            return short.class;
-        if ("int".equals(className))
-            return int.class;
-        if ("long".equals(className))
-            return long.class;
-        if ("float".equals(className))
-            return float.class;
-        if ("double".equals(className))
-            return double.class;
-        if ("boolean[]".equals(className))
-            return boolean[].class;
-        if ("byte[]".equals(className))
-            return byte[].class;
-        if ("char[]".equals(className))
-            return char[].class;
-        if ("short[]".equals(className))
-            return short[].class;
-        if ("int[]".equals(className))
-            return int[].class;
-        if ("long[]".equals(className))
-            return long[].class;
-        if ("float[]".equals(className))
-            return float[].class;
-        if ("double[]".equals(className))
-            return double[].class;
+        switch(className){
+            case "boolean":
+                return boolean.class;
+            case "byte":
+                return byte.class;
+            case "char":
+                return char.class;
+            case "short":
+                return short.class;
+            case "int":
+                return int.class;
+            case "long":
+                return long.class;
+            case "float":
+                return float.class;
+            case "double":
+                return double.class;
+            case "boolean[]":
+                return boolean[].class;
+            case "byte[]":
+                return byte[].class;
+            case "char[]":
+                return char[].class;
+            case "short[]":
+                return short[].class;
+            case "int[]":
+                return int[].class;
+            case "long[]":
+                return long[].class;
+            case "float[]":
+                return float[].class;
+            case "double[]":
+                return double[].class;
+        }
         try {
             return arrayForName(className);
         } catch (ClassNotFoundException e) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org