This commit is contained in:
Looly 2019-10-16 10:09:19 +08:00
parent 106556248d
commit 8bd07803e4
8 changed files with 18 additions and 26 deletions

View File

@ -161,8 +161,8 @@ Hutool欢迎任何人为Hutool添砖加瓦贡献代码不过作者是一
1. 在Gitee或者Github上fork项目到自己的repo
2. 把fork过去的项目也就是你的项目clone到你的本地
3. 修改代码记得一定要修改v4-dev分支
4. commit后push到自己的库v4-dev分支
3. 修改代码记得一定要修改v5-dev分支
4. commit后push到自己的库v5-dev分支
5. 登录Gitee或Github在你首页可以看到一个 pull request 按钮,点击它,填写一些说明信息,然后提交即可。
6. 等待作者合并

View File

@ -266,11 +266,7 @@ public abstract class AbsSetting extends OptNullBasicTypeFromStringGetter<String
@Override
public Object value(String key, Type valueType) {
final String value = getByGroup(key, group);
// if (null != value) {
// log.debug("Parse setting to object field [{}={}]", key, value);
// }
return value;
return getByGroup(key, group);
}
@Override

View File

@ -63,6 +63,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
*
* @return 总键值对数
*/
@Override
public int size() {
writeLock.lock();
try {
@ -90,11 +91,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
group = StrUtil.nullToEmpty(group).trim();
writeLock.lock();
try {
LinkedHashMap<String, String> valueMap = this.get(group);
if (null == valueMap) {
valueMap = new LinkedHashMap<>();
this.put(group, valueMap);
}
final LinkedHashMap<String, String> valueMap = this.computeIfAbsent(group, k -> new LinkedHashMap<>());
this.size = -1;
return valueMap.put(key, value);
} finally {

View File

@ -199,7 +199,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
try {
reader = IoUtil.getReader(settingStream, charset);
// 分组
String group = null;
String group;
LinkedHashSet<String> valueSet = null;
while (true) {
@ -223,7 +223,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
group = line.substring(1, line.length() - 1).trim();
valueSet = super.get(group);
if (null == valueSet) {
valueSet = new LinkedHashSet<String>();
valueSet = new LinkedHashSet<>();
}
super.put(group, valueSet);
continue;
@ -232,7 +232,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
// 添加值
if (null == valueSet) {
// 当出现无分组值的时候会导致valueSet为空此时group为""
valueSet = new LinkedHashSet<String>();
valueSet = new LinkedHashSet<>();
super.put(StrUtil.EMPTY, valueSet);
}
valueSet.add(line);

View File

@ -258,14 +258,14 @@ public class Setting extends AbsSetting implements Map<String, String> {
* @since 3.1.2
*/
public String getAndRemoveStr(String... keys) {
Object value = null;
String value = null;
for (String key : keys) {
value = remove(key);
if (null != value) {
break;
}
}
return (String) value;
return value;
}
/**
@ -276,7 +276,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
*/
public Map<String, String> getMap(String group) {
final LinkedHashMap<String, String> map = this.groupedMap.get(group);
return (null != map) ? map : new LinkedHashMap<String, String>(0);
return (null != map) ? map : new LinkedHashMap<>(0);
}
/**
@ -692,13 +692,10 @@ public class Setting extends AbsSetting implements Map<String, String> {
return false;
}
if (settingUrl == null) {
if (other.settingUrl != null) {
return false;
}
} else if (!settingUrl.equals(other.settingUrl)) {
return false;
return other.settingUrl == null;
} else {
return settingUrl.equals(other.settingUrl);
}
return true;
}
@Override

View File

@ -202,7 +202,7 @@ public class SettingLoader {
*/
private String replaceVar(String group, String value) {
// 找到所有变量标识
final Set<String> vars = ReUtil.findAll(varRegex, value, 0, new HashSet<String>());
final Set<String> vars = ReUtil.findAll(varRegex, value, 0, new HashSet<>());
String key;
for (String var : vars) {
key = ReUtil.get(varRegex, var, 1);

View File

@ -16,7 +16,7 @@ import cn.hutool.core.util.StrUtil;
public class SettingUtil {
/** 配置文件缓存 */
private static Map<String, Setting> settingMap = new ConcurrentHashMap<>();
private static Object lock = new Object();
private static final Object lock = new Object();
/**
* 获取当前环境下的配置文件<br>

View File

@ -16,6 +16,8 @@ import oshi.software.os.OperatingSystem;
* 1系统信息
* 2硬件信息
* </pre>
*
* 相关内容见https://github.com/oshi/oshi
*
* @author Looly
* @since 4.6.4