mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -5,9 +5,9 @@ import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import cn.hutool.core.bean.copier.ValueProvider;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.getter.OptNullBasicTypeFromStringGetter;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.core.reflect.ReflectUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.log.Log;
|
||||
import cn.hutool.log.LogFactory;
|
||||
|
||||
@@ -47,7 +47,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
*/
|
||||
public String getStr(String key, String group, String defaultValue) {
|
||||
final String value = getByGroup(key, group);
|
||||
return ObjectUtil.defaultIfNull(value, defaultValue);
|
||||
return ObjUtil.defaultIfNull(value, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
*/
|
||||
public String getStrNotEmpty(String key, String group, String defaultValue) {
|
||||
final String value = getByGroup(key, group);
|
||||
return ObjectUtil.defaultIfEmpty(value, defaultValue);
|
||||
return ObjUtil.defaultIfEmpty(value, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.setting;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -16,7 +16,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
/**
|
||||
* 基于分组的Map<br>
|
||||
* 此对象方法线程安全
|
||||
*
|
||||
*
|
||||
* @author looly
|
||||
* @since 4.0.11
|
||||
*/
|
||||
@@ -30,7 +30,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 获取分组对应的值,如果分组不存在或者值不存在则返回null
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @param key 键
|
||||
* @return 值,如果分组不存在或者值不存在则返回null
|
||||
@@ -60,7 +60,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 总的键值对数
|
||||
*
|
||||
*
|
||||
* @return 总键值对数
|
||||
*/
|
||||
@Override
|
||||
@@ -81,7 +81,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 将键值对加入到对应分组中
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @param key 键
|
||||
* @param value 值
|
||||
@@ -101,7 +101,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 加入多个键值对到某个分组下
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @param m 键值对
|
||||
* @return this
|
||||
@@ -115,7 +115,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 从指定分组中删除指定值
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @param key 键
|
||||
* @return 被删除的值,如果值不存在,返回null
|
||||
@@ -136,7 +136,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 某个分组对应的键值对是否为空
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @return 是否为空
|
||||
*/
|
||||
@@ -156,7 +156,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 是否为空,如果多个分组同时为空,也按照空处理
|
||||
*
|
||||
*
|
||||
* @return 是否为空,如果多个分组同时为空,也按照空处理
|
||||
*/
|
||||
@Override
|
||||
@@ -166,7 +166,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 指定分组中是否包含指定key
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @param key 键
|
||||
* @return 是否包含key
|
||||
@@ -187,7 +187,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 指定分组中是否包含指定值
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @param value 值
|
||||
* @return 是否包含值
|
||||
@@ -208,7 +208,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 清除指定分组下的所有键值对
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @return this
|
||||
*/
|
||||
@@ -238,7 +238,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 指定分组所有键的Set
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @return 键Set
|
||||
*/
|
||||
@@ -258,7 +258,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 指定分组下所有值
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @return 值
|
||||
*/
|
||||
@@ -288,7 +288,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
|
||||
/**
|
||||
* 指定分组下所有键值对
|
||||
*
|
||||
*
|
||||
* @param group 分组
|
||||
* @return 键值对
|
||||
*/
|
||||
|
@@ -5,8 +5,8 @@ import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.net.URLUtil;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
@@ -25,19 +25,19 @@ import java.util.Set;
|
||||
* 在配置文件中可以用中括号分隔不同的分组,每个分组会放在独立的Set中,用group区别<br>
|
||||
* 无分组的集合和`[]`分组集合会合并成员,重名的分组也会合并成员<br>
|
||||
* 分组配置文件如下:
|
||||
*
|
||||
*
|
||||
* <pre>
|
||||
* [group1]
|
||||
* aaa
|
||||
* bbb
|
||||
* ccc
|
||||
*
|
||||
*
|
||||
* [group2]
|
||||
* aaa
|
||||
* ccc
|
||||
* ddd
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @author Looly
|
||||
* @since 3.1.0
|
||||
*/
|
||||
@@ -58,7 +58,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
/**
|
||||
* 基本构造<br>
|
||||
* 需自定义初始化配置文件
|
||||
*
|
||||
*
|
||||
* @param charset 字符集
|
||||
*/
|
||||
public GroupedSet(Charset charset) {
|
||||
@@ -67,7 +67,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
|
||||
/**
|
||||
* 构造,使用相对于Class文件根目录的相对路径
|
||||
*
|
||||
*
|
||||
* @param pathBaseClassLoader 相对路径(相对于当前项目的classes路径)
|
||||
* @param charset 字符集
|
||||
*/
|
||||
@@ -85,7 +85,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param configFile 配置文件对象
|
||||
* @param charset 字符集
|
||||
*/
|
||||
@@ -99,7 +99,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
|
||||
/**
|
||||
* 构造,相对于classes读取文件
|
||||
*
|
||||
*
|
||||
* @param path 相对路径
|
||||
* @param clazz 基准类
|
||||
* @param charset 字符集
|
||||
@@ -114,7 +114,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param url 设定文件的URL
|
||||
* @param charset 字符集
|
||||
*/
|
||||
@@ -127,17 +127,17 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
*
|
||||
* @param pathBaseClassLoader 相对路径(相对于当前项目的classes路径)
|
||||
*/
|
||||
public GroupedSet(String pathBaseClassLoader) {
|
||||
this(pathBaseClassLoader, CharsetUtil.CHARSET_UTF_8);
|
||||
this(pathBaseClassLoader, CharsetUtil.UTF_8);
|
||||
}
|
||||
|
||||
/*--------------------------公有方法 start-------------------------------*/
|
||||
/**
|
||||
* 初始化设定文件
|
||||
*
|
||||
*
|
||||
* @param groupedSetUrl 设定文件的URL
|
||||
* @param charset 字符集
|
||||
* @return 成功初始化与否
|
||||
@@ -154,7 +154,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
|
||||
/**
|
||||
* 加载设置文件
|
||||
*
|
||||
*
|
||||
* @param groupedSetUrl 配置文件URL
|
||||
* @return 加载是否成功
|
||||
*/
|
||||
@@ -185,7 +185,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
|
||||
/**
|
||||
* 加载设置文件。 此方法不会关闭流对象
|
||||
*
|
||||
*
|
||||
* @param settingStream 文件流
|
||||
* @return 加载成功与否
|
||||
* @throws IOException IO异常
|
||||
@@ -256,7 +256,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
|
||||
/**
|
||||
* 获得对应分组的所有值
|
||||
*
|
||||
*
|
||||
* @param group 分组名
|
||||
* @return 分组的值集合
|
||||
*/
|
||||
@@ -270,7 +270,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
/**
|
||||
* 是否在给定分组的集合中包含指定值<br>
|
||||
* 如果给定分组对应集合不存在,则返回false
|
||||
*
|
||||
*
|
||||
* @param group 分组名
|
||||
* @param value 测试的值
|
||||
* @param otherValues 其他值
|
||||
@@ -278,7 +278,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
*/
|
||||
public boolean contains(String group, String value, String... otherValues) {
|
||||
if (ArrayUtil.isNotEmpty(otherValues)) {
|
||||
// 需要测试多个值的情况
|
||||
// 需要测试多个值的情况
|
||||
final List<String> valueList = ListUtil.toList(otherValues);
|
||||
valueList.add(value);
|
||||
return contains(group, valueList);
|
||||
@@ -296,7 +296,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
/**
|
||||
* 是否在给定分组的集合中全部包含指定值集合<br>
|
||||
* 如果给定分组对应集合不存在,则返回false
|
||||
*
|
||||
*
|
||||
* @param group 分组名
|
||||
* @param values 测试的值集合
|
||||
* @return 是否包含
|
||||
|
@@ -15,7 +15,7 @@ import cn.hutool.core.io.watch.WatchUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.log.StaticLog;
|
||||
import cn.hutool.setting.dialect.Props;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
/**
|
||||
* 默认字符集
|
||||
*/
|
||||
public static final Charset DEFAULT_CHARSET = CharsetUtil.CHARSET_UTF_8;
|
||||
public static final Charset DEFAULT_CHARSET = CharsetUtil.UTF_8;
|
||||
/**
|
||||
* 默认配置文件扩展名
|
||||
*/
|
||||
|
@@ -7,7 +7,7 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.regex.ReUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.core.util.SystemPropsUtil;
|
||||
import cn.hutool.log.Log;
|
||||
|
||||
@@ -52,7 +52,7 @@ public class SettingLoader {
|
||||
* @param groupedMap GroupedMap
|
||||
*/
|
||||
public SettingLoader(GroupedMap groupedMap) {
|
||||
this(groupedMap, CharsetUtil.CHARSET_UTF_8, false);
|
||||
this(groupedMap, CharsetUtil.UTF_8, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package cn.hutool.setting;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
/**
|
||||
* 设置异常
|
||||
|
@@ -2,7 +2,7 @@ package cn.hutool.setting;
|
||||
|
||||
import cn.hutool.core.io.file.FileNameUtil;
|
||||
import cn.hutool.core.io.resource.NoResourceException;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@@ -18,8 +18,8 @@ import cn.hutool.core.io.watch.WatchUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ReflectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.reflect.ReflectUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.log.StaticLog;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -69,7 +69,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* properties文件编码<br>
|
||||
* issue#1701,此属性不能被序列化,故忽略序列化
|
||||
*/
|
||||
private transient Charset charset = CharsetUtil.CHARSET_ISO_8859_1;
|
||||
private transient Charset charset = CharsetUtil.ISO_8859_1;
|
||||
// ----------------------------------------------------------------------- 私有属性 end
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param path 配置文件路径,相对于ClassPath,或者使用绝对路径
|
||||
*/
|
||||
public Props(String path) {
|
||||
this(path, CharsetUtil.CHARSET_ISO_8859_1);
|
||||
this(path, CharsetUtil.ISO_8859_1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +183,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param clazz 基准类
|
||||
*/
|
||||
public Props(String path, Class<?> clazz) {
|
||||
this(path, clazz, CharsetUtil.ISO_8859_1);
|
||||
this(path, clazz, CharsetUtil.NAME_ISO_8859_1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,7 +2,7 @@ package cn.hutool.setting.dialect;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.io.resource.NoResourceException;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package cn.hutool.setting.profile;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import cn.hutool.setting.Setting;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@@ -31,6 +31,6 @@ public class YamlUtilTest {
|
||||
|
||||
YamlUtil.dump(
|
||||
dict
|
||||
, FileUtil.getWriter("d:/test/dump.yaml", CharsetUtil.CHARSET_UTF_8, false));
|
||||
, FileUtil.getWriter("d:/test/dump.yaml", CharsetUtil.UTF_8, false));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user