!854 update 优化使用getFirst()替代get(0)以提高代码可读性
* update 优化使用getFirst()替代get(0)以提高代码可读性
This commit is contained in:
+1
-1
@@ -64,7 +64,7 @@ public class TreeBuildUtils extends TreeUtil {
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return CollUtil.newArrayList();
|
||||
}
|
||||
K k = ReflectUtils.invokeGetter(list.get(0), "parentId");
|
||||
K k = ReflectUtils.invokeGetter(list.getFirst(), "parentId");
|
||||
return TreeUtil.build(list, k, DEFAULT_CONFIG, nodeParser);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class CellMergeHandler {
|
||||
}
|
||||
|
||||
// 获取有合并注解的字段
|
||||
Map<Field, FieldColumnIndex> mergeFields = getFieldColumnIndexMap(rows.get(0).getClass());
|
||||
Map<Field, FieldColumnIndex> mergeFields = getFieldColumnIndexMap(rows.getFirst().getClass());
|
||||
// 如果没有需要合并的字段则返回空集
|
||||
if (CollUtil.isEmpty(mergeFields)) {
|
||||
return Collections.emptyList();
|
||||
|
||||
+1
-1
@@ -154,7 +154,7 @@ public class DropDownOptions {
|
||||
sonList.forEach(everySon -> {
|
||||
if (parentGroupByIdMap.containsKey(sonHowToGetParentIdFunction.apply(everySon))) {
|
||||
// 找到对应的上级
|
||||
T parentObj = parentGroupByIdMap.get(sonHowToGetParentIdFunction.apply(everySon)).get(0);
|
||||
T parentObj = parentGroupByIdMap.get(sonHowToGetParentIdFunction.apply(everySon)).getFirst();
|
||||
// 提取名称和ID作为Key
|
||||
String key = howToBuildEveryOption.apply(parentObj);
|
||||
// Key对应的Value
|
||||
|
||||
+2
-2
@@ -282,10 +282,10 @@ public class ExcelDownHandler implements SheetWriteHandler {
|
||||
continue;
|
||||
}
|
||||
// 取第一个
|
||||
String str = data.get(0);
|
||||
String str = data.getFirst();
|
||||
rowData.add(str);
|
||||
// 通过移除的方式避免重复
|
||||
data.remove(0);
|
||||
data.removeFirst();
|
||||
// 设置可以继续
|
||||
flag = true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class PlusDataPermissionHandler {
|
||||
}
|
||||
Object defaultValue = "-1";
|
||||
NullSafeStandardEvaluationContext context = new NullSafeStandardEvaluationContext(defaultValue);
|
||||
context.addPropertyAccessor(new NullSafePropertyAccessor(context.getPropertyAccessors().get(0), defaultValue));
|
||||
context.addPropertyAccessor(new NullSafePropertyAccessor(context.getPropertyAccessors().getFirst(), defaultValue));
|
||||
context.setBeanResolver(beanResolver);
|
||||
DataPermissionHelper.getContext().forEach(context::setVariable);
|
||||
Set<String> conditions = new HashSet<>();
|
||||
|
||||
Reference in New Issue
Block a user