From e27eb9299bd740c05e95cc5313822ab1293188cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=99=B4=E9=9B=A8=E5=A4=9C?= <758366855@qq.com>
Date: Wed, 26 Aug 2020 15:10:26 +0800
Subject: [PATCH] =?UTF-8?q?fix(5.4.1):=20=E4=BF=AE=E6=94=B9code=20smell?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
1.静态工具类构造器私有
2.优化过长方法名
---
.../hutool/core/annotation/LeafCollection.java | 6 +++++-
.../cn/hutool/core/lang/tree/TreeConvert.java | 16 ++++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/hutool-core/src/main/java/cn/hutool/core/annotation/LeafCollection.java b/hutool-core/src/main/java/cn/hutool/core/annotation/LeafCollection.java
index a05852149..3d3bfe146 100644
--- a/hutool-core/src/main/java/cn/hutool/core/annotation/LeafCollection.java
+++ b/hutool-core/src/main/java/cn/hutool/core/annotation/LeafCollection.java
@@ -1,6 +1,10 @@
package cn.hutool.core.annotation;
-import java.lang.annotation.*;
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+import java.lang.annotation.RetentionPolicy;
/**
* 叶容器-当对象存在树型结构,通过此注解标注属性告知存储位置
diff --git a/hutool-core/src/main/java/cn/hutool/core/lang/tree/TreeConvert.java b/hutool-core/src/main/java/cn/hutool/core/lang/tree/TreeConvert.java
index d50dfb21c..d45f4661b 100644
--- a/hutool-core/src/main/java/cn/hutool/core/lang/tree/TreeConvert.java
+++ b/hutool-core/src/main/java/cn/hutool/core/lang/tree/TreeConvert.java
@@ -10,7 +10,9 @@ import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
-import java.util.*;
+import java.util.List;
+import java.util.Collection;
+import java.util.ArrayList;
/**
* 树结构转换工具
@@ -26,6 +28,13 @@ import java.util.*;
*/
public class TreeConvert {
+ /**
+ * 构造私有化,静态方法不需要暴露公共构造器
+ * 修复 Add a private constructor to hide the implicit public one
+ */
+ private TreeConvert() {
+
+ }
/**
* 生成树结构
* 通过反射检测LeafCollection注解,转换为父子结构容器,子数据装入LeafCollection容器中
@@ -87,8 +96,11 @@ public class TreeConvert {
* @throws IntrospectionException e
* @throws InvocationTargetException e
* @throws IllegalAccessException e
+ *
+ * 2020-08-26 修复方法名过长
*/
- private static List sort(T root, Collection elements, LeafDecide leafDecide, Class> clazz, Field leafField) throws IntrospectionException, InvocationTargetException, IllegalAccessException {
+ private static List sort(T root, Collection elements, LeafDecide leafDecide, Class> clazz, Field leafField)
+ throws IntrospectionException, InvocationTargetException, IllegalAccessException {
List subMenu = null;
for (T element : elements) {
if (leafDecide.isLeaf(root, element)) {