You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by hu...@apache.org on 2018/05/17 09:34:03 UTC

[incubator-dubbo] branch master updated: Simplify code, no function change.

This is an automated email from the ASF dual-hosted git repository.

huxing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo.git


The following commit(s) were added to refs/heads/master by this push:
     new 6db0cd1  Simplify code, no function change.
6db0cd1 is described below

commit 6db0cd152acc1abaff229029bae86aa1268a6af1
Author: Huxing Zhang <hu...@gmail.com>
AuthorDate: Thu May 17 17:32:43 2018 +0800

    Simplify code, no function change.
---
 .../com/alibaba/dubbo/config/AbstractConfig.java   | 25 +++++++++++-----------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java
index 8d8d182..84ad29e 100644
--- a/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java
+++ b/dubbo-config/dubbo-config-api/src/main/java/com/alibaba/dubbo/config/AbstractConfig.java
@@ -117,16 +117,16 @@ public abstract class AbstractConfig implements Serializable {
                     if (value == null || value.length() == 0) {
                         Method getter;
                         try {
-                            getter = config.getClass().getMethod("get" + name.substring(3), new Class<?>[0]);
+                            getter = config.getClass().getMethod("get" + name.substring(3));
                         } catch (NoSuchMethodException e) {
                             try {
-                                getter = config.getClass().getMethod("is" + name.substring(3), new Class<?>[0]);
+                                getter = config.getClass().getMethod("is" + name.substring(3));
                             } catch (NoSuchMethodException e2) {
                                 getter = null;
                             }
                         }
                         if (getter != null) {
-                            if (getter.invoke(config, new Object[0]) == null) {
+                            if (getter.invoke(config) == null) {
                                 if (config.getId() != null && config.getId().length() > 0) {
                                     value = ConfigUtils.getProperty(prefix + config.getId() + "." + property);
                                 }
@@ -144,7 +144,7 @@ public abstract class AbstractConfig implements Serializable {
                         }
                     }
                     if (value != null && value.length() > 0) {
-                        method.invoke(config, new Object[]{convertPrimitive(method.getParameterTypes()[0], value)});
+                        method.invoke(config, convertPrimitive(method.getParameterTypes()[0], value));
                     }
                 }
             } catch (Exception e) {
@@ -190,12 +190,12 @@ public abstract class AbstractConfig implements Serializable {
                     int i = name.startsWith("get") ? 3 : 2;
                     String prop = StringUtils.camelToSplitName(name.substring(i, i + 1).toLowerCase() + name.substring(i + 1), ".");
                     String key;
-                    if (parameter != null && parameter.key() != null && parameter.key().length() > 0) {
+                    if (parameter != null && parameter.key().length() > 0) {
                         key = parameter.key();
                     } else {
                         key = prop;
                     }
-                    Object value = method.invoke(config, new Object[0]);
+                    Object value = method.invoke(config);
                     String str = String.valueOf(value).trim();
                     if (value != null && str.length() > 0) {
                         if (parameter != null && parameter.escaped()) {
@@ -257,13 +257,14 @@ public abstract class AbstractConfig implements Serializable {
                     if (parameter == null || !parameter.attribute())
                         continue;
                     String key;
-                    if (parameter.key() != null && parameter.key().length() > 0) {
+                    parameter.key();
+                    if (parameter.key().length() > 0) {
                         key = parameter.key();
                     } else {
                         int i = name.startsWith("get") ? 3 : 2;
                         key = name.substring(i, i + 1).toLowerCase() + name.substring(i + 1);
                     }
-                    Object value = method.invoke(config, new Object[0]);
+                    Object value = method.invoke(config);
                     if (value != null) {
                         if (prefix != null && prefix.length() > 0) {
                             key = prefix + "." + key;
@@ -418,7 +419,7 @@ public abstract class AbstractConfig implements Serializable {
                         property = "interface";
                     }
                     String setter = "set" + property.substring(0, 1).toUpperCase() + property.substring(1);
-                    Object value = method.invoke(annotation, new Object[0]);
+                    Object value = method.invoke(annotation);
                     if (value != null && !value.equals(method.getDefaultValue())) {
                         Class<?> parameterType = ReflectUtils.getBoxedClass(method.getReturnType());
                         if ("filter".equals(property) || "listener".equals(property)) {
@@ -429,8 +430,8 @@ public abstract class AbstractConfig implements Serializable {
                             value = CollectionUtils.toStringMap((String[]) value);
                         }
                         try {
-                            Method setterMethod = getClass().getMethod(setter, new Class<?>[]{parameterType});
-                            setterMethod.invoke(this, new Object[]{value});
+                            Method setterMethod = getClass().getMethod(setter, parameterType);
+                            setterMethod.invoke(this, value);
                         } catch (NoSuchMethodException e) {
                             // ignore
                         }
@@ -459,7 +460,7 @@ public abstract class AbstractConfig implements Serializable {
                             && isPrimitive(method.getReturnType())) {
                         int i = name.startsWith("get") ? 3 : 2;
                         String key = name.substring(i, i + 1).toLowerCase() + name.substring(i + 1);
-                        Object value = method.invoke(this, new Object[0]);
+                        Object value = method.invoke(this);
                         if (value != null) {
                             buf.append(" ");
                             buf.append(key);

-- 
To stop receiving notification emails like this one, please contact
huxing@apache.org.