From c3636f1527cfc0041a7b54396da7f4ff2dd71e4f Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期三, 16 六月 2021 19:24:44 +0800
Subject: [PATCH] update 更新 feign demo 更清晰的用法
---
ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java
index 7ffa94c..c5d17d8 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java
@@ -4,6 +4,7 @@
import cn.hutool.core.util.StrUtil;
import java.lang.reflect.Method;
+import java.util.List;
/**
* 鍙嶅皠宸ュ叿绫�. 鎻愪緵璋冪敤getter/setter鏂规硶, 璁块棶绉佹湁鍙橀噺, 璋冪敤绉佹湁鏂规硶, 鑾峰彇娉涘瀷绫诲瀷Class, 琚獳OP杩囩殑鐪熷疄绫荤瓑宸ュ叿鍑芥暟.
@@ -37,13 +38,13 @@
*/
public static <E> void invokeSetter(Object obj, String propertyName, E value) {
Object object = obj;
- String[] names = StrUtil.split(propertyName, ".");
- for (int i = 0; i < names.length; i++) {
- if (i < names.length - 1) {
- String getterMethodName = GETTER_PREFIX + StrUtil.upperFirst(names[i]);
+ List<String> names = StrUtil.split(propertyName, ".");
+ for (int i = 0; i < names.size(); i++) {
+ if (i < names.size() - 1) {
+ String getterMethodName = GETTER_PREFIX + StrUtil.upperFirst(names.get(i));
object = invoke(object, getterMethodName);
} else {
- String setterMethodName = SETTER_PREFIX + StrUtil.upperFirst(names[i]);
+ String setterMethodName = SETTER_PREFIX + StrUtil.upperFirst(names.get(i));
Method method = getMethodByName(object.getClass(), setterMethodName);
invoke(object, method, value);
}
--
Gitblit v1.9.3