mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -1,14 +1,5 @@
|
||||
package cn.hutool.core.bean;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import cn.hutool.core.annotation.Alias;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.CaseInsensitiveMap;
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
@@ -18,6 +9,14 @@ import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.TypeUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Bean信息描述做为BeanInfo替代方案,此对象持有JavaBean中的setters和getters等相关信息描述<br>
|
||||
* 查找Getter和Setter方法时会:
|
||||
@@ -322,7 +321,7 @@ public class BeanDesc implements Serializable{
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字段名,如果存在{@link Alias}注解,读取注解的值作为名称
|
||||
* 获取字段名,如果存在Alias注解,读取注解的值作为名称
|
||||
*
|
||||
* @return 字段名
|
||||
*/
|
||||
|
@@ -2,8 +2,6 @@ package cn.hutool.core.bean.copier;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
|
||||
/**
|
||||
* 值提供者,用于提供Bean注入时参数对应值得抽象接口<br>
|
||||
* 继承或匿名实例化此接口<br>
|
||||
@@ -17,7 +15,7 @@ public interface ValueProvider<T>{
|
||||
|
||||
/**
|
||||
* 获取值<br>
|
||||
* 返回值一般需要匹配被注入类型,如果不匹配会调用默认转换 {@link Convert#convert(Type, Object)}实现转换
|
||||
* 返回值一般需要匹配被注入类型,如果不匹配会调用默认转换 Convert#convert(Type, Object)实现转换
|
||||
*
|
||||
* @param key Bean对象中参数名
|
||||
* @param valueType 被注入的值得类型
|
||||
|
@@ -25,9 +25,9 @@ public class GenericEnumConverter<E extends Enum<E>> extends AbstractConverter<E
|
||||
this.enumClass = enumClass;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
protected E convertInternal(Object value) {
|
||||
//noinspection unchecked
|
||||
E enumValue = (E) EnumConverter.tryConvertEnum(value, this.enumClass);
|
||||
if(null == enumValue && false == value instanceof String){
|
||||
// 最后尝试valueOf转换
|
||||
|
@@ -1,5 +1,12 @@
|
||||
package cn.hutool.core.io.file;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.copier.SrcToDestCopier;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.CopyOption;
|
||||
@@ -7,12 +14,6 @@ import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.IORuntimeException;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.copier.SrcToDestCopier;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 文件拷贝器<br>
|
||||
* 支持以下几种情况:
|
||||
@@ -209,25 +210,28 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
|
||||
//被过滤的目录跳过
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (false == dest.exists()) {
|
||||
//目标为不存在路径,创建为目录
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
dest.mkdirs();
|
||||
} else if (false == dest.isDirectory()) {
|
||||
throw new IORuntimeException(StrUtil.format("Src [{}] is a directory but dest [{}] is a file!", src.getPath(), dest.getPath()));
|
||||
}
|
||||
|
||||
final String[] files = src.list();
|
||||
File srcFile;
|
||||
File destFile;
|
||||
for (String file : files) {
|
||||
srcFile = new File(src, file);
|
||||
destFile = this.isOnlyCopyFile ? dest : new File(dest, file);
|
||||
// 递归复制
|
||||
if (srcFile.isDirectory()) {
|
||||
internalCopyDirContent(srcFile, destFile);
|
||||
} else {
|
||||
internalCopyFile(srcFile, destFile);
|
||||
if(ArrayUtil.isNotEmpty(files)){
|
||||
File srcFile;
|
||||
File destFile;
|
||||
for (String file : files) {
|
||||
srcFile = new File(src, file);
|
||||
destFile = this.isOnlyCopyFile ? dest : new File(dest, file);
|
||||
// 递归复制
|
||||
if (srcFile.isDirectory()) {
|
||||
internalCopyDirContent(srcFile, destFile);
|
||||
} else {
|
||||
internalCopyFile(srcFile, destFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,6 +267,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
|
||||
}
|
||||
}else {
|
||||
//路径不存在则创建父目录
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
dest.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
@@ -275,7 +280,7 @@ public class FileCopier extends SrcToDestCopier<File, FileCopier>{
|
||||
}
|
||||
|
||||
try {
|
||||
Files.copy(src.toPath(), dest.toPath(), optionList.toArray(new CopyOption[optionList.size()]));
|
||||
Files.copy(src.toPath(), dest.toPath(), optionList.toArray(new CopyOption[0]));
|
||||
} catch (IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
|
@@ -1,11 +1,5 @@
|
||||
package cn.hutool.core.net.multipart;
|
||||
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.setting.Setting;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* 上传文件设定文件
|
||||
*
|
||||
@@ -13,10 +7,6 @@ import java.net.URL;
|
||||
*
|
||||
*/
|
||||
public class UploadSetting {
|
||||
private static final Log log = Log.get();
|
||||
|
||||
/** 默认的配置文件路径(相对ClassPath) */
|
||||
public final static String DEFAULT_SETTING_PATH = "config/upload.setting";
|
||||
|
||||
/** 最大文件大小,默认无限制 */
|
||||
protected int maxFileSize = -1;
|
||||
@@ -117,32 +107,4 @@ public class UploadSetting {
|
||||
this.isAllowFileExts = isAllowFileExts;
|
||||
}
|
||||
// ---------------------------------------------------------------------- Setters and Getters end
|
||||
|
||||
/**
|
||||
* 加载全局设定<br>
|
||||
* 使用默认的配置文件classpath/config/upload.setting
|
||||
*/
|
||||
public void load() {
|
||||
load(DEFAULT_SETTING_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载全局设定
|
||||
*
|
||||
* @param settingPath 设定文件路径,相对Classpath
|
||||
*/
|
||||
synchronized public void load(String settingPath) {
|
||||
URL url = URLUtil.getURL(settingPath);
|
||||
if (url == null) {
|
||||
log.info("Can not find Upload setting file [{}], use default setting.", settingPath);
|
||||
return;
|
||||
}
|
||||
Setting setting = new Setting(url, Setting.DEFAULT_CHARSET, true);
|
||||
|
||||
maxFileSize = setting.getInt("file.size.max");
|
||||
memoryThreshold = setting.getInt("memory.threshold");
|
||||
tmpUploadPath = setting.getStr("tmp.upload.path");
|
||||
fileExts = setting.getStrings("file.exts");
|
||||
isAllowFileExts = setting.getBool("file.exts.allow");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user