mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -33,7 +33,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
public final static String DEFAULT_GROUP = StrUtil.EMPTY;
|
||||
|
||||
@Override
|
||||
public String getStr(String key, String defaultValue) {
|
||||
public String getStr(final String key, final String defaultValue) {
|
||||
return getStr(key, DEFAULT_GROUP, defaultValue);
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param defaultValue 默认值
|
||||
* @return 值,如果字符串为{@code null}返回默认值
|
||||
*/
|
||||
public String getStr(String key, String group, String defaultValue) {
|
||||
public String getStr(final String key, final String group, final String defaultValue) {
|
||||
final String value = getByGroup(key, group);
|
||||
return ObjUtil.defaultIfNull(value, defaultValue);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @return 值,如果字符串为{@code null}或者""返回默认值
|
||||
* @since 5.2。4
|
||||
*/
|
||||
public String getStrNotEmpty(String key, String group, String defaultValue) {
|
||||
public String getStrNotEmpty(final String key, final String group, final String defaultValue) {
|
||||
final String value = getByGroup(key, group);
|
||||
return ObjUtil.defaultIfEmpty(value, defaultValue);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param key 键
|
||||
* @return 值
|
||||
*/
|
||||
public String getWithLog(String key) {
|
||||
public String getWithLog(final String key) {
|
||||
final String value = getStr(key);
|
||||
if (value == null) {
|
||||
log.debug("No key define for [{}]!", key);
|
||||
@@ -96,7 +96,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param group 分组
|
||||
* @return 值
|
||||
*/
|
||||
public String getByGroupWithLog(String key, String group) {
|
||||
public String getByGroupWithLog(final String key, final String group) {
|
||||
final String value = getByGroup(key, group);
|
||||
if (value == null) {
|
||||
log.debug("No key define for [{}] of group [{}] !", key, group);
|
||||
@@ -112,7 +112,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param key 属性名
|
||||
* @return 属性值
|
||||
*/
|
||||
public String[] getStrings(String key) {
|
||||
public String[] getStrings(final String key) {
|
||||
return getStrings(key, null);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param defaultValue 默认的值
|
||||
* @return 属性值
|
||||
*/
|
||||
public String[] getStringsWithDefault(String key, String[] defaultValue) {
|
||||
public String[] getStringsWithDefault(final String key, final String[] defaultValue) {
|
||||
String[] value = getStrings(key, null);
|
||||
if (null == value) {
|
||||
value = defaultValue;
|
||||
@@ -139,7 +139,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param group 分组名
|
||||
* @return 属性值
|
||||
*/
|
||||
public String[] getStrings(String key, String group) {
|
||||
public String[] getStrings(final String key, final String group) {
|
||||
return getStrings(key, group, DEFAULT_DELIMITER);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param delimiter 分隔符
|
||||
* @return 属性值
|
||||
*/
|
||||
public String[] getStrings(String key, String group, String delimiter) {
|
||||
public String[] getStrings(final String key, final String group, final String delimiter) {
|
||||
final String value = getByGroup(key, group);
|
||||
if (StrUtil.isBlank(value)) {
|
||||
return null;
|
||||
@@ -168,7 +168,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param group 分组名
|
||||
* @return 属性值
|
||||
*/
|
||||
public Integer getInt(String key, String group) {
|
||||
public Integer getInt(final String key, final String group) {
|
||||
return getInt(key, group, null);
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param defaultValue 默认值
|
||||
* @return 属性值
|
||||
*/
|
||||
public Integer getInt(String key, String group, Integer defaultValue) {
|
||||
public Integer getInt(final String key, final String group, final Integer defaultValue) {
|
||||
return Convert.toInt(getByGroup(key, group), defaultValue);
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param group 分组名
|
||||
* @return 属性值
|
||||
*/
|
||||
public Boolean getBool(String key, String group) {
|
||||
public Boolean getBool(final String key, final String group) {
|
||||
return getBool(key, group, null);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param defaultValue 默认值
|
||||
* @return 属性值
|
||||
*/
|
||||
public Boolean getBool(String key, String group, Boolean defaultValue) {
|
||||
public Boolean getBool(final String key, final String group, final Boolean defaultValue) {
|
||||
return Convert.toBool(getByGroup(key, group), defaultValue);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param group 分组名
|
||||
* @return 属性值
|
||||
*/
|
||||
public Long getLong(String key, String group) {
|
||||
public Long getLong(final String key, final String group) {
|
||||
return getLong(key, group, null);
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param defaultValue 默认值
|
||||
* @return 属性值
|
||||
*/
|
||||
public Long getLong(String key, String group, Long defaultValue) {
|
||||
public Long getLong(final String key, final String group, final Long defaultValue) {
|
||||
return Convert.toLong(getByGroup(key, group), defaultValue);
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param group 分组名
|
||||
* @return 属性值
|
||||
*/
|
||||
public Character getChar(String key, String group) {
|
||||
public Character getChar(final String key, final String group) {
|
||||
final String value = getByGroup(key, group);
|
||||
if (StrUtil.isBlank(value)) {
|
||||
return null;
|
||||
@@ -260,7 +260,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param group 分组名
|
||||
* @return 属性值
|
||||
*/
|
||||
public Double getDouble(String key, String group) {
|
||||
public Double getDouble(final String key, final String group) {
|
||||
return getDouble(key, group, null);
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param defaultValue 默认值
|
||||
* @return 属性值
|
||||
*/
|
||||
public Double getDouble(String key, String group, Double defaultValue) {
|
||||
public Double getDouble(final String key, final String group, final Double defaultValue) {
|
||||
return Convert.toDouble(getByGroup(key, group), defaultValue);
|
||||
}
|
||||
|
||||
@@ -285,16 +285,16 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param bean Bean对象
|
||||
* @return Bean
|
||||
*/
|
||||
public <T> T toBean(final String group, T bean) {
|
||||
public <T> T toBean(final String group, final T bean) {
|
||||
return BeanUtil.fillBean(bean, new ValueProvider<String>() {
|
||||
|
||||
@Override
|
||||
public Object value(String key, Type valueType) {
|
||||
public Object value(final String key, final Type valueType) {
|
||||
return getByGroup(key, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(String key) {
|
||||
public boolean containsKey(final String key) {
|
||||
return null != getByGroup(key, group);
|
||||
}
|
||||
}, CopyOptions.create());
|
||||
@@ -310,7 +310,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @return Bean
|
||||
* @since 5.0.6
|
||||
*/
|
||||
public <T> T toBean(String group, Class<T> beanClass) {
|
||||
public <T> T toBean(final String group, final Class<T> beanClass) {
|
||||
return toBean(group, ReflectUtil.newInstanceIfPossible(beanClass));
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @param bean Bean
|
||||
* @return Bean
|
||||
*/
|
||||
public <T> T toBean(T bean) {
|
||||
public <T> T toBean(final T bean) {
|
||||
return toBean(null, bean);
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ public abstract class AbsSetting implements OptNullBasicTypeFromStringGetter<Str
|
||||
* @return Bean
|
||||
* @since 5.0.6
|
||||
*/
|
||||
public <T> T toBean(Class<T> beanClass) {
|
||||
public <T> T toBean(final Class<T> beanClass) {
|
||||
return toBean(null, beanClass);
|
||||
}
|
||||
}
|
||||
|
@@ -35,10 +35,10 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
* @param key 键
|
||||
* @return 值,如果分组不存在或者值不存在则返回null
|
||||
*/
|
||||
public String get(String group, String key) {
|
||||
public String get(final String group, final String key) {
|
||||
readLock.lock();
|
||||
try {
|
||||
LinkedHashMap<String, String> map = this.get(StrUtil.nullToEmpty(group));
|
||||
final LinkedHashMap<String, String> map = this.get(StrUtil.nullToEmpty(group));
|
||||
if (MapUtil.isNotEmpty(map)) {
|
||||
return map.get(key);
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinkedHashMap<String, String> get(Object key) {
|
||||
public LinkedHashMap<String, String> get(final Object key) {
|
||||
readLock.lock();
|
||||
try {
|
||||
return super.get(key);
|
||||
@@ -69,7 +69,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
try {
|
||||
if (this.size < 0) {
|
||||
this.size = 0;
|
||||
for (LinkedHashMap<String, String> value : this.values()) {
|
||||
for (final LinkedHashMap<String, String> value : this.values()) {
|
||||
this.size += value.size();
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
* @param value 值
|
||||
* @return 此key之前存在的值,如果没有返回null
|
||||
*/
|
||||
public String put(String group, String key, String value) {
|
||||
public String put(String group, final String key, final String value) {
|
||||
group = StrUtil.nullToEmpty(group).trim();
|
||||
writeLock.lock();
|
||||
try {
|
||||
@@ -106,8 +106,8 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
* @param m 键值对
|
||||
* @return this
|
||||
*/
|
||||
public GroupedMap putAll(String group, Map<? extends String, ? extends String> m) {
|
||||
for (Entry<? extends String, ? extends String> entry : m.entrySet()) {
|
||||
public GroupedMap putAll(final String group, final Map<? extends String, ? extends String> m) {
|
||||
for (final Entry<? extends String, ? extends String> entry : m.entrySet()) {
|
||||
this.put(group, entry.getKey(), entry.getValue());
|
||||
}
|
||||
return this;
|
||||
@@ -120,7 +120,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
* @param key 键
|
||||
* @return 被删除的值,如果值不存在,返回null
|
||||
*/
|
||||
public String remove(String group, String key) {
|
||||
public String remove(String group, final String key) {
|
||||
group = StrUtil.nullToEmpty(group).trim();
|
||||
writeLock.lock();
|
||||
try {
|
||||
@@ -171,7 +171,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
* @param key 键
|
||||
* @return 是否包含key
|
||||
*/
|
||||
public boolean containsKey(String group, String key) {
|
||||
public boolean containsKey(String group, final String key) {
|
||||
group = StrUtil.nullToEmpty(group).trim();
|
||||
readLock.lock();
|
||||
try {
|
||||
@@ -192,7 +192,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
||||
* @param value 值
|
||||
* @return 是否包含值
|
||||
*/
|
||||
public boolean containsValue(String group, String value) {
|
||||
public boolean containsValue(String group, final String value) {
|
||||
group = StrUtil.nullToEmpty(group).trim();
|
||||
readLock.lock();
|
||||
try {
|
||||
|
@@ -61,7 +61,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
*
|
||||
* @param charset 字符集
|
||||
*/
|
||||
public GroupedSet(Charset charset) {
|
||||
public GroupedSet(final Charset charset) {
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
* @param pathBaseClassLoader 相对路径(相对于当前项目的classes路径)
|
||||
* @param charset 字符集
|
||||
*/
|
||||
public GroupedSet(String pathBaseClassLoader, Charset charset) {
|
||||
public GroupedSet(String pathBaseClassLoader, final Charset charset) {
|
||||
if (null == pathBaseClassLoader) {
|
||||
pathBaseClassLoader = StrUtil.EMPTY;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
* @param configFile 配置文件对象
|
||||
* @param charset 字符集
|
||||
*/
|
||||
public GroupedSet(File configFile, Charset charset) {
|
||||
public GroupedSet(final File configFile, final Charset charset) {
|
||||
if (configFile == null) {
|
||||
throw new RuntimeException("Null GroupSet file!");
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
* @param clazz 基准类
|
||||
* @param charset 字符集
|
||||
*/
|
||||
public GroupedSet(String path, Class<?> clazz, Charset charset) {
|
||||
public GroupedSet(final String path, final Class<?> clazz, final Charset charset) {
|
||||
final URL url = URLUtil.getURL(path, clazz);
|
||||
if (url == null) {
|
||||
throw new RuntimeException(StrUtil.format("Can not find GroupSet file: [{}]", path));
|
||||
@@ -118,7 +118,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
* @param url 设定文件的URL
|
||||
* @param charset 字符集
|
||||
*/
|
||||
public GroupedSet(URL url, Charset charset) {
|
||||
public GroupedSet(final URL url, final Charset charset) {
|
||||
if (url == null) {
|
||||
throw new RuntimeException("Null url define!");
|
||||
}
|
||||
@@ -130,7 +130,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
*
|
||||
* @param pathBaseClassLoader 相对路径(相对于当前项目的classes路径)
|
||||
*/
|
||||
public GroupedSet(String pathBaseClassLoader) {
|
||||
public GroupedSet(final String pathBaseClassLoader) {
|
||||
this(pathBaseClassLoader, CharsetUtil.UTF_8);
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
* @param charset 字符集
|
||||
* @return 成功初始化与否
|
||||
*/
|
||||
public boolean init(URL groupedSetUrl, Charset charset) {
|
||||
public boolean init(final URL groupedSetUrl, final Charset charset) {
|
||||
if (groupedSetUrl == null) {
|
||||
throw new RuntimeException("Null GroupSet url or charset define!");
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
* @param groupedSetUrl 配置文件URL
|
||||
* @return 加载是否成功
|
||||
*/
|
||||
synchronized public boolean load(URL groupedSetUrl) {
|
||||
synchronized public boolean load(final URL groupedSetUrl) {
|
||||
if (groupedSetUrl == null) {
|
||||
throw new RuntimeException("Null GroupSet url define!");
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
try {
|
||||
settingStream = groupedSetUrl.openStream();
|
||||
load(settingStream);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
// log.error(e, "Load GroupSet error!");
|
||||
return false;
|
||||
} finally {
|
||||
@@ -190,7 +190,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
* @return 加载成功与否
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
public boolean load(InputStream settingStream) throws IOException {
|
||||
public boolean load(final InputStream settingStream) throws IOException {
|
||||
super.clear();
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
@@ -276,7 +276,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
* @param otherValues 其他值
|
||||
* @return 是否包含
|
||||
*/
|
||||
public boolean contains(String group, String value, String... otherValues) {
|
||||
public boolean contains(final String group, final String value, final String... otherValues) {
|
||||
if (ArrayUtil.isNotEmpty(otherValues)) {
|
||||
// 需要测试多个值的情况
|
||||
final List<String> valueList = ListUtil.toList(otherValues);
|
||||
@@ -301,7 +301,7 @@ public class GroupedSet extends HashMap<String, LinkedHashSet<String>> {
|
||||
* @param values 测试的值集合
|
||||
* @return 是否包含
|
||||
*/
|
||||
public boolean contains(String group, Collection<String> values) {
|
||||
public boolean contains(final String group, final Collection<String> values) {
|
||||
final LinkedHashSet<String> valueSet = getValues(group);
|
||||
if (CollUtil.isEmpty(values) || CollUtil.isEmpty(valueSet)) {
|
||||
return false;
|
||||
|
@@ -102,7 +102,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
*
|
||||
* @param path 相对路径或绝对路径
|
||||
*/
|
||||
public Setting(String path) {
|
||||
public Setting(final String path) {
|
||||
this(path, false);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param path 相对路径或绝对路径
|
||||
* @param isUseVariable 是否使用变量
|
||||
*/
|
||||
public Setting(String path, boolean isUseVariable) {
|
||||
public Setting(final String path, final boolean isUseVariable) {
|
||||
this(path, DEFAULT_CHARSET, isUseVariable);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param charset 字符集
|
||||
* @param isUseVariable 是否使用变量
|
||||
*/
|
||||
public Setting(String path, Charset charset, boolean isUseVariable) {
|
||||
public Setting(final String path, final Charset charset, final boolean isUseVariable) {
|
||||
Assert.notBlank(path, "Blank setting path !");
|
||||
this.init(ResourceUtil.getResourceObj(path), charset, isUseVariable);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param charset 字符集
|
||||
* @param isUseVariable 是否使用变量
|
||||
*/
|
||||
public Setting(File configFile, Charset charset, boolean isUseVariable) {
|
||||
public Setting(final File configFile, final Charset charset, final boolean isUseVariable) {
|
||||
Assert.notNull(configFile, "Null setting file define!");
|
||||
this.init(new FileResource(configFile), charset, isUseVariable);
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param charset 字符集
|
||||
* @param isUseVariable 是否使用变量
|
||||
*/
|
||||
public Setting(String path, Class<?> clazz, Charset charset, boolean isUseVariable) {
|
||||
public Setting(final String path, final Class<?> clazz, final Charset charset, final boolean isUseVariable) {
|
||||
Assert.notBlank(path, "Blank setting path !");
|
||||
this.init(new ClassPathResource(path, clazz), charset, isUseVariable);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param charset 字符集
|
||||
* @param isUseVariable 是否使用变量
|
||||
*/
|
||||
public Setting(URL url, Charset charset, boolean isUseVariable) {
|
||||
public Setting(final URL url, final Charset charset, final boolean isUseVariable) {
|
||||
Assert.notNull(url, "Null setting url define!");
|
||||
this.init(new UrlResource(url), charset, isUseVariable);
|
||||
}
|
||||
@@ -173,7 +173,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param isUseVariable 是否使用变量
|
||||
* @since 5.4.4
|
||||
*/
|
||||
public Setting(Resource resource, Charset charset, boolean isUseVariable) {
|
||||
public Setting(final Resource resource, final Charset charset, final boolean isUseVariable) {
|
||||
this.init(resource, charset, isUseVariable);
|
||||
}
|
||||
// ------------------------------------------------------------------------------------- Constructor end
|
||||
@@ -186,7 +186,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param isUseVariable 是否使用变量
|
||||
* @return 成功初始化与否
|
||||
*/
|
||||
public boolean init(Resource resource, Charset charset, boolean isUseVariable) {
|
||||
public boolean init(final Resource resource, final Charset charset, final boolean isUseVariable) {
|
||||
Assert.notNull(resource, "Setting resource must be not null!");
|
||||
this.resource = resource;
|
||||
this.charset = charset;
|
||||
@@ -212,7 +212,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
*
|
||||
* @param autoReload 是否自动加载
|
||||
*/
|
||||
public void autoLoad(boolean autoReload) {
|
||||
public void autoLoad(final boolean autoReload) {
|
||||
autoLoad(autoReload, null);
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param callback 加载完成回调
|
||||
* @param autoReload 是否自动加载
|
||||
*/
|
||||
public void autoLoad(boolean autoReload, Consumer<Boolean> callback) {
|
||||
public void autoLoad(final boolean autoReload, final Consumer<Boolean> callback) {
|
||||
if (autoReload) {
|
||||
Assert.notNull(this.resource, "Setting resource must be not null !");
|
||||
if (null != this.watchMonitor) {
|
||||
@@ -231,8 +231,8 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
}
|
||||
this.watchMonitor = WatchUtil.createModify(resource.getUrl(), new SimpleWatcher() {
|
||||
@Override
|
||||
public void onModify(WatchEvent<?> event, Path currentPath) {
|
||||
boolean success = load();
|
||||
public void onModify(final WatchEvent<?> event, final Path currentPath) {
|
||||
final boolean success = load();
|
||||
// 如果有回调,加载完毕则执行回调
|
||||
if (callback != null) {
|
||||
callback.accept(success);
|
||||
@@ -278,7 +278,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getByGroup(String key, String group) {
|
||||
public String getByGroup(final String key, final String group) {
|
||||
return this.groupedMap.get(group, key);
|
||||
}
|
||||
|
||||
@@ -289,9 +289,9 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return 值
|
||||
* @since 3.1.2
|
||||
*/
|
||||
public Object getAndRemove(String... keys) {
|
||||
public Object getAndRemove(final String... keys) {
|
||||
Object value = null;
|
||||
for (String key : keys) {
|
||||
for (final String key : keys) {
|
||||
value = remove(key);
|
||||
if (null != value) {
|
||||
break;
|
||||
@@ -307,9 +307,9 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return 字符串值
|
||||
* @since 3.1.2
|
||||
*/
|
||||
public String getAndRemoveStr(String... keys) {
|
||||
public String getAndRemoveStr(final String... keys) {
|
||||
String value = null;
|
||||
for (String key : keys) {
|
||||
for (final String key : keys) {
|
||||
value = remove(key);
|
||||
if (null != value) {
|
||||
break;
|
||||
@@ -324,7 +324,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param group 分组
|
||||
* @return map
|
||||
*/
|
||||
public Map<String, String> getMap(String group) {
|
||||
public Map<String, String> getMap(final String group) {
|
||||
final LinkedHashMap<String, String> map = this.groupedMap.get(group);
|
||||
return (null != map) ? map : new LinkedHashMap<>(0);
|
||||
}
|
||||
@@ -335,7 +335,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param group 分组
|
||||
* @return Setting
|
||||
*/
|
||||
public Setting getSetting(String group) {
|
||||
public Setting getSetting(final String group) {
|
||||
final Setting setting = new Setting();
|
||||
setting.putAll(this.getMap(group));
|
||||
return setting;
|
||||
@@ -347,7 +347,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param group 分组
|
||||
* @return Properties对象
|
||||
*/
|
||||
public Properties getProperties(String group) {
|
||||
public Properties getProperties(final String group) {
|
||||
final Properties properties = new Properties();
|
||||
properties.putAll(getMap(group));
|
||||
return properties;
|
||||
@@ -360,7 +360,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return Props对象
|
||||
* @since 4.1.21
|
||||
*/
|
||||
public Props getProps(String group) {
|
||||
public Props getProps(final String group) {
|
||||
final Props props = new Props();
|
||||
props.putAll(getMap(group));
|
||||
return props;
|
||||
@@ -386,7 +386,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
*
|
||||
* @param absolutePath 设置文件的绝对路径
|
||||
*/
|
||||
public void store(String absolutePath) {
|
||||
public void store(final String absolutePath) {
|
||||
store(FileUtil.touch(absolutePath));
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param file 设置文件
|
||||
* @since 5.4.3
|
||||
*/
|
||||
public void store(File file) {
|
||||
public void store(final File file) {
|
||||
if (null == this.settingLoader) {
|
||||
settingLoader = new SettingLoader(this.groupedMap, this.charset, this.isUseVariable);
|
||||
}
|
||||
@@ -412,9 +412,9 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
public Properties toProperties() {
|
||||
final Properties properties = new Properties();
|
||||
String group;
|
||||
for (Entry<String, LinkedHashMap<String, String>> groupEntry : this.groupedMap.entrySet()) {
|
||||
for (final Entry<String, LinkedHashMap<String, String>> groupEntry : this.groupedMap.entrySet()) {
|
||||
group = groupEntry.getKey();
|
||||
for (Entry<String, String> entry : groupEntry.getValue().entrySet()) {
|
||||
for (final Entry<String, String> entry : groupEntry.getValue().entrySet()) {
|
||||
properties.setProperty(StrUtil.isEmpty(group) ? entry.getKey() : group + CharUtil.DOT + entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
@@ -447,7 +447,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param regex 正则
|
||||
* @return this
|
||||
*/
|
||||
public Setting setVarRegex(String regex) {
|
||||
public Setting setVarRegex(final String regex) {
|
||||
if (null == this.settingLoader) {
|
||||
throw new NullPointerException("SettingLoader is null !");
|
||||
}
|
||||
@@ -462,7 +462,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return this
|
||||
* @since 4.6.2
|
||||
*/
|
||||
public Setting setCharset(Charset charset) {
|
||||
public Setting setCharset(final Charset charset) {
|
||||
this.charset = charset;
|
||||
return this;
|
||||
}
|
||||
@@ -475,7 +475,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param group 分组
|
||||
* @return 是否为空
|
||||
*/
|
||||
public boolean isEmpty(String group) {
|
||||
public boolean isEmpty(final String group) {
|
||||
return this.groupedMap.isEmpty(group);
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param key 键
|
||||
* @return 是否包含key
|
||||
*/
|
||||
public boolean containsKey(String group, String key) {
|
||||
public boolean containsKey(final String group, final String key) {
|
||||
return this.groupedMap.containsKey(group, key);
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param value 值
|
||||
* @return 是否包含值
|
||||
*/
|
||||
public boolean containsValue(String group, String value) {
|
||||
public boolean containsValue(final String group, final String value) {
|
||||
return this.groupedMap.containsValue(group, value);
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param key 键
|
||||
* @return 值,如果分组不存在或者值不存在则返回null
|
||||
*/
|
||||
public String get(String group, String key) {
|
||||
public String get(final String group, final String key) {
|
||||
return this.groupedMap.get(group, key);
|
||||
}
|
||||
|
||||
@@ -520,7 +520,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param value 值
|
||||
* @return 此key之前存在的值,如果没有返回null
|
||||
*/
|
||||
public String putByGroup(String key, String group, String value) {
|
||||
public String putByGroup(final String key, final String group, final String value) {
|
||||
return this.groupedMap.put(group, key, value);
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param key 键
|
||||
* @return 被删除的值,如果值不存在,返回null
|
||||
*/
|
||||
public String remove(String group, Object key) {
|
||||
public String remove(final String group, final Object key) {
|
||||
return this.groupedMap.remove(group, Convert.toStr(key));
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param m 键值对
|
||||
* @return this
|
||||
*/
|
||||
public Setting putAll(String group, Map<? extends String, ? extends String> m) {
|
||||
public Setting putAll(final String group, final Map<? extends String, ? extends String> m) {
|
||||
this.groupedMap.putAll(group, m);
|
||||
return this;
|
||||
}
|
||||
@@ -554,8 +554,8 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return this
|
||||
* @since 5.2.4
|
||||
*/
|
||||
public Setting addSetting(Setting setting) {
|
||||
for (Entry<String, LinkedHashMap<String, String>> e : setting.getGroupedMap().entrySet()) {
|
||||
public Setting addSetting(final Setting setting) {
|
||||
for (final Entry<String, LinkedHashMap<String, String>> e : setting.getGroupedMap().entrySet()) {
|
||||
this.putAll(e.getKey(), e.getValue());
|
||||
}
|
||||
return this;
|
||||
@@ -567,7 +567,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param group 分组
|
||||
* @return this
|
||||
*/
|
||||
public Setting clear(String group) {
|
||||
public Setting clear(final String group) {
|
||||
this.groupedMap.clear(group);
|
||||
return this;
|
||||
}
|
||||
@@ -578,7 +578,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param group 分组
|
||||
* @return 键Set
|
||||
*/
|
||||
public Set<String> keySet(String group) {
|
||||
public Set<String> keySet(final String group) {
|
||||
return this.groupedMap.keySet(group);
|
||||
}
|
||||
|
||||
@@ -588,7 +588,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param group 分组
|
||||
* @return 值
|
||||
*/
|
||||
public Collection<String> values(String group) {
|
||||
public Collection<String> values(final String group) {
|
||||
return this.groupedMap.values(group);
|
||||
}
|
||||
|
||||
@@ -598,7 +598,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @param group 分组
|
||||
* @return 键值对
|
||||
*/
|
||||
public Set<Entry<String, String>> entrySet(String group) {
|
||||
public Set<Entry<String, String>> entrySet(final String group) {
|
||||
return this.groupedMap.entrySet(group);
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return this
|
||||
* @since 3.3.1
|
||||
*/
|
||||
public Setting set(String key, String value) {
|
||||
public Setting set(final String key, final String value) {
|
||||
this.put(key, value);
|
||||
return this;
|
||||
}
|
||||
@@ -625,7 +625,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return 此key之前存在的值,如果没有返回null
|
||||
* @since 5.5.7
|
||||
*/
|
||||
public Setting setByGroup(String key, String group, String value) {
|
||||
public Setting setByGroup(final String key, final String group, final String value) {
|
||||
this.putByGroup(key, group, value);
|
||||
return this;
|
||||
}
|
||||
@@ -643,7 +643,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return 默认分组中是否包含指定key对应的值
|
||||
*/
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
public boolean containsKey(final Object key) {
|
||||
return this.groupedMap.containsKey(DEFAULT_GROUP, Convert.toStr(key));
|
||||
}
|
||||
|
||||
@@ -654,7 +654,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return 默认分组中是否包含指定值
|
||||
*/
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
public boolean containsValue(final Object value) {
|
||||
return this.groupedMap.containsValue(DEFAULT_GROUP, Convert.toStr(value));
|
||||
}
|
||||
|
||||
@@ -665,7 +665,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return 默认分组(空分组)中指定key对应的值
|
||||
*/
|
||||
@Override
|
||||
public String get(Object key) {
|
||||
public String get(final Object key) {
|
||||
return this.groupedMap.get(DEFAULT_GROUP, Convert.toStr(key));
|
||||
}
|
||||
|
||||
@@ -677,7 +677,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return 加入的值
|
||||
*/
|
||||
@Override
|
||||
public String put(String key, String value) {
|
||||
public String put(final String key, final String value) {
|
||||
return this.groupedMap.put(DEFAULT_GROUP, key, value);
|
||||
}
|
||||
|
||||
@@ -688,7 +688,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
* @return 移除的值
|
||||
*/
|
||||
@Override
|
||||
public String remove(Object key) {
|
||||
public String remove(final Object key) {
|
||||
return this.groupedMap.remove(DEFAULT_GROUP, Convert.toStr(key));
|
||||
}
|
||||
|
||||
@@ -699,7 +699,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
*/
|
||||
@SuppressWarnings("NullableProblems")
|
||||
@Override
|
||||
public void putAll(Map<? extends String, ? extends String> m) {
|
||||
public void putAll(final Map<? extends String, ? extends String> m) {
|
||||
this.groupedMap.putAll(DEFAULT_GROUP, m);
|
||||
}
|
||||
|
||||
@@ -756,7 +756,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
@@ -766,7 +766,7 @@ public class Setting extends AbsSetting implements Map<String, String> {
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Setting other = (Setting) obj;
|
||||
final Setting other = (Setting) obj;
|
||||
if (charset == null) {
|
||||
if (other.charset != null) {
|
||||
return false;
|
||||
|
@@ -51,7 +51,7 @@ public class SettingLoader {
|
||||
*
|
||||
* @param groupedMap GroupedMap
|
||||
*/
|
||||
public SettingLoader(GroupedMap groupedMap) {
|
||||
public SettingLoader(final GroupedMap groupedMap) {
|
||||
this(groupedMap, CharsetUtil.UTF_8, false);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class SettingLoader {
|
||||
* @param charset 编码
|
||||
* @param isUseVariable 是否使用变量
|
||||
*/
|
||||
public SettingLoader(GroupedMap groupedMap, Charset charset, boolean isUseVariable) {
|
||||
public SettingLoader(final GroupedMap groupedMap, final Charset charset, final boolean isUseVariable) {
|
||||
this.groupedMap = groupedMap;
|
||||
this.charset = charset;
|
||||
this.isUseVariable = isUseVariable;
|
||||
@@ -74,7 +74,7 @@ public class SettingLoader {
|
||||
* @param resource 配置文件URL
|
||||
* @return 加载是否成功
|
||||
*/
|
||||
public boolean load(Resource resource) {
|
||||
public boolean load(final Resource resource) {
|
||||
if (resource == null) {
|
||||
throw new NullPointerException("Null setting url define!");
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class SettingLoader {
|
||||
try {
|
||||
settingStream = resource.getStream();
|
||||
load(settingStream);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
log.error(e, "Load setting error!");
|
||||
return false;
|
||||
} finally {
|
||||
@@ -99,7 +99,7 @@ public class SettingLoader {
|
||||
* @return 加载成功与否
|
||||
* @throws IOException IO异常
|
||||
*/
|
||||
synchronized public boolean load(InputStream settingStream) throws IOException {
|
||||
synchronized public boolean load(final InputStream settingStream) throws IOException {
|
||||
this.groupedMap.clear();
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
@@ -150,7 +150,7 @@ public class SettingLoader {
|
||||
*
|
||||
* @param regex 正则
|
||||
*/
|
||||
public void setVarRegex(String regex) {
|
||||
public void setVarRegex(final String regex) {
|
||||
this.varRegex = regex;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public class SettingLoader {
|
||||
* @param assignFlag 正则
|
||||
* @since 4.6.5
|
||||
*/
|
||||
public void setAssignFlag(char assignFlag) {
|
||||
public void setAssignFlag(final char assignFlag) {
|
||||
this.assignFlag = assignFlag;
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public class SettingLoader {
|
||||
*
|
||||
* @param absolutePath 设置文件的绝对路径
|
||||
*/
|
||||
public void store(String absolutePath) {
|
||||
public void store(final String absolutePath) {
|
||||
store(FileUtil.touch(absolutePath));
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ public class SettingLoader {
|
||||
* @param file 设置文件
|
||||
* @since 5.4.3
|
||||
*/
|
||||
public void store(File file) {
|
||||
public void store(final File file) {
|
||||
Assert.notNull(file, "File to store must be not null !");
|
||||
log.debug("Store Setting to [{}]...", file.getAbsolutePath());
|
||||
PrintWriter writer = null;
|
||||
@@ -198,10 +198,10 @@ public class SettingLoader {
|
||||
*
|
||||
* @param writer Writer
|
||||
*/
|
||||
synchronized private void store(PrintWriter writer) {
|
||||
for (Entry<String, LinkedHashMap<String, String>> groupEntry : this.groupedMap.entrySet()) {
|
||||
synchronized private void store(final PrintWriter writer) {
|
||||
for (final Entry<String, LinkedHashMap<String, String>> groupEntry : this.groupedMap.entrySet()) {
|
||||
writer.println(StrUtil.format("{}{}{}", CharUtil.BRACKET_START, groupEntry.getKey(), CharUtil.BRACKET_END));
|
||||
for (Entry<String, String> entry : groupEntry.getValue().entrySet()) {
|
||||
for (final Entry<String, String> entry : groupEntry.getValue().entrySet()) {
|
||||
writer.println(StrUtil.format("{} {} {}", entry.getKey(), this.assignFlag, entry.getValue()));
|
||||
}
|
||||
}
|
||||
@@ -215,11 +215,11 @@ public class SettingLoader {
|
||||
* @param value 值
|
||||
* @return 替换后的字符串
|
||||
*/
|
||||
private String replaceVar(String group, String value) {
|
||||
private String replaceVar(final String group, String value) {
|
||||
// 找到所有变量标识
|
||||
final Set<String> vars = ReUtil.findAll(varRegex, value, 0, new HashSet<>());
|
||||
String key;
|
||||
for (String var : vars) {
|
||||
for (final String var : vars) {
|
||||
key = ReUtil.get(varRegex, var, 1);
|
||||
if (StrUtil.isNotBlank(key)) {
|
||||
// 本分组中查找变量名对应的值
|
||||
|
@@ -10,27 +10,27 @@ import cn.hutool.core.text.StrUtil;
|
||||
public class SettingRuntimeException extends RuntimeException {
|
||||
private static final long serialVersionUID = 7941096116780378387L;
|
||||
|
||||
public SettingRuntimeException(Throwable e) {
|
||||
public SettingRuntimeException(final Throwable e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public SettingRuntimeException(String message) {
|
||||
public SettingRuntimeException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SettingRuntimeException(String messageTemplate, Object... params) {
|
||||
public SettingRuntimeException(final String messageTemplate, final Object... params) {
|
||||
super(StrUtil.format(messageTemplate, params));
|
||||
}
|
||||
|
||||
public SettingRuntimeException(String message, Throwable throwable) {
|
||||
public SettingRuntimeException(final String message, final Throwable throwable) {
|
||||
super(message, throwable);
|
||||
}
|
||||
|
||||
public SettingRuntimeException(String message, Throwable throwable, boolean enableSuppression, boolean writableStackTrace) {
|
||||
public SettingRuntimeException(final String message, final Throwable throwable, final boolean enableSuppression, final boolean writableStackTrace) {
|
||||
super(message, throwable, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
public SettingRuntimeException(Throwable throwable, String messageTemplate, Object... params) {
|
||||
public SettingRuntimeException(final Throwable throwable, final String messageTemplate, final Object... params) {
|
||||
super(StrUtil.format(messageTemplate, params), throwable);
|
||||
}
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ public class SettingUtil {
|
||||
* @param name 文件名,如果没有扩展名,默认为.setting
|
||||
* @return 当前环境下配置文件
|
||||
*/
|
||||
public static Setting get(String name) {
|
||||
public static Setting get(final String name) {
|
||||
return SETTING_MAP.computeIfAbsent(name, (filePath)->{
|
||||
final String extName = FileNameUtil.extName(filePath);
|
||||
if (StrUtil.isEmpty(extName)) {
|
||||
@@ -45,11 +45,11 @@ public class SettingUtil {
|
||||
* @return 当前环境下配置文件
|
||||
* @since 5.1.3
|
||||
*/
|
||||
public static Setting getFirstFound(String... names) {
|
||||
for (String name : names) {
|
||||
public static Setting getFirstFound(final String... names) {
|
||||
for (final String name : names) {
|
||||
try {
|
||||
return get(name);
|
||||
} catch (NoResourceException e) {
|
||||
} catch (final NoResourceException e) {
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
|
@@ -78,7 +78,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param resource 资源(相对Classpath的路径)
|
||||
* @return Props
|
||||
*/
|
||||
public static Props getProp(String resource) {
|
||||
public static Props getProp(final String resource) {
|
||||
return new Props(resource);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param charsetName 字符集
|
||||
* @return Properties
|
||||
*/
|
||||
public static Props getProp(String resource, String charsetName) {
|
||||
public static Props getProp(final String resource, final String charsetName) {
|
||||
return new Props(resource, charsetName);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param charset 字符集
|
||||
* @return Properties
|
||||
*/
|
||||
public static Props getProp(String resource, Charset charset) {
|
||||
public static Props getProp(final String resource, final Charset charset) {
|
||||
return new Props(resource, charset);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
*
|
||||
* @param path 配置文件路径,相对于ClassPath,或者使用绝对路径
|
||||
*/
|
||||
public Props(String path) {
|
||||
public Props(final String path) {
|
||||
this(path, CharsetUtil.ISO_8859_1);
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param path 相对或绝对路径
|
||||
* @param charsetName 字符集
|
||||
*/
|
||||
public Props(String path, String charsetName) {
|
||||
public Props(final String path, final String charsetName) {
|
||||
this(path, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param path 相对或绝对路径
|
||||
* @param charset 字符集
|
||||
*/
|
||||
public Props(String path, Charset charset) {
|
||||
public Props(final String path, final Charset charset) {
|
||||
Assert.notBlank(path, "Blank properties file path !");
|
||||
if (null != charset) {
|
||||
this.charset = charset;
|
||||
@@ -150,7 +150,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
*
|
||||
* @param propertiesFile 配置文件对象
|
||||
*/
|
||||
public Props(File propertiesFile) {
|
||||
public Props(final File propertiesFile) {
|
||||
this(propertiesFile, StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param propertiesFile 配置文件对象
|
||||
* @param charsetName 字符集
|
||||
*/
|
||||
public Props(File propertiesFile, String charsetName) {
|
||||
public Props(final File propertiesFile, final String charsetName) {
|
||||
this(propertiesFile, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param propertiesFile 配置文件对象
|
||||
* @param charset 字符集
|
||||
*/
|
||||
public Props(File propertiesFile, Charset charset) {
|
||||
public Props(final File propertiesFile, final Charset charset) {
|
||||
Assert.notNull(propertiesFile, "Null properties file!");
|
||||
this.charset = charset;
|
||||
this.load(new FileResource(propertiesFile));
|
||||
@@ -182,7 +182,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param path 相对路径
|
||||
* @param clazz 基准类
|
||||
*/
|
||||
public Props(String path, Class<?> clazz) {
|
||||
public Props(final String path, final Class<?> clazz) {
|
||||
this(path, clazz, CharsetUtil.NAME_ISO_8859_1);
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param clazz 基准类
|
||||
* @param charsetName 字符集
|
||||
*/
|
||||
public Props(String path, Class<?> clazz, String charsetName) {
|
||||
public Props(final String path, final Class<?> clazz, final String charsetName) {
|
||||
this(path, clazz, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param clazz 基准类
|
||||
* @param charset 字符集
|
||||
*/
|
||||
public Props(String path, Class<?> clazz, Charset charset) {
|
||||
public Props(final String path, final Class<?> clazz, final Charset charset) {
|
||||
Assert.notBlank(path, "Blank properties file path !");
|
||||
if (null != charset) {
|
||||
this.charset = charset;
|
||||
@@ -217,7 +217,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
*
|
||||
* @param propertiesUrl 属性文件路径
|
||||
*/
|
||||
public Props(URL propertiesUrl) {
|
||||
public Props(final URL propertiesUrl) {
|
||||
this(propertiesUrl, StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param propertiesUrl 属性文件路径
|
||||
* @param charsetName 字符集
|
||||
*/
|
||||
public Props(URL propertiesUrl, String charsetName) {
|
||||
public Props(final URL propertiesUrl, final String charsetName) {
|
||||
this(propertiesUrl, CharsetUtil.charset(charsetName));
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param propertiesUrl 属性文件路径
|
||||
* @param charset 字符集
|
||||
*/
|
||||
public Props(URL propertiesUrl, Charset charset) {
|
||||
public Props(final URL propertiesUrl, final Charset charset) {
|
||||
Assert.notNull(propertiesUrl, "Null properties URL !");
|
||||
if (null != charset) {
|
||||
this.charset = charset;
|
||||
@@ -250,7 +250,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
*
|
||||
* @param properties 属性文件路径
|
||||
*/
|
||||
public Props(Properties properties) {
|
||||
public Props(final Properties properties) {
|
||||
if (MapUtil.isNotEmpty(properties)) {
|
||||
this.putAll(properties);
|
||||
}
|
||||
@@ -264,7 +264,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param url {@link URL}
|
||||
* @since 5.5.2
|
||||
*/
|
||||
public void load(URL url) {
|
||||
public void load(final URL url) {
|
||||
load(new UrlResource(url));
|
||||
}
|
||||
|
||||
@@ -273,13 +273,13 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
*
|
||||
* @param resource {@link Resource}
|
||||
*/
|
||||
public void load(Resource resource) {
|
||||
public void load(final Resource resource) {
|
||||
Assert.notNull(resource, "Props resource must be not null!");
|
||||
this.resource = resource;
|
||||
|
||||
try (final BufferedReader reader = resource.getReader(charset)) {
|
||||
super.load(reader);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e);
|
||||
}
|
||||
}
|
||||
@@ -296,7 +296,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
*
|
||||
* @param autoReload 是否自动加载
|
||||
*/
|
||||
public void autoLoad(boolean autoReload) {
|
||||
public void autoLoad(final boolean autoReload) {
|
||||
if (autoReload) {
|
||||
Assert.notNull(this.resource, "Properties resource must be not null!");
|
||||
if (null != this.watchMonitor) {
|
||||
@@ -305,7 +305,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
}
|
||||
this.watchMonitor = WatchUtil.createModify(this.resource.getUrl(), new SimpleWatcher() {
|
||||
@Override
|
||||
public void onModify(WatchEvent<?> event, Path currentPath) {
|
||||
public void onModify(final WatchEvent<?> event, final Path currentPath) {
|
||||
load();
|
||||
}
|
||||
});
|
||||
@@ -318,57 +318,57 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
// ----------------------------------------------------------------------- Get start
|
||||
@Override
|
||||
public Object getObj(String key, Object defaultValue) {
|
||||
public Object getObj(final String key, final Object defaultValue) {
|
||||
return getStr(key, null == defaultValue ? null : defaultValue.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getObj(String key) {
|
||||
public Object getObj(final String key) {
|
||||
return getObj(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStr(String key, String defaultValue) {
|
||||
public String getStr(final String key, final String defaultValue) {
|
||||
return super.getProperty(key, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStr(String key) {
|
||||
public String getStr(final String key) {
|
||||
return super.getProperty(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getInt(String key, Integer defaultValue) {
|
||||
public Integer getInt(final String key, final Integer defaultValue) {
|
||||
return Convert.toInt(getStr(key), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getInt(String key) {
|
||||
public Integer getInt(final String key) {
|
||||
return getInt(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getBool(String key, Boolean defaultValue) {
|
||||
public Boolean getBool(final String key, final Boolean defaultValue) {
|
||||
return Convert.toBool(getStr(key), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getBool(String key) {
|
||||
public Boolean getBool(final String key) {
|
||||
return getBool(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getLong(String key, Long defaultValue) {
|
||||
public Long getLong(final String key, final Long defaultValue) {
|
||||
return Convert.toLong(getStr(key), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getLong(String key) {
|
||||
public Long getLong(final String key) {
|
||||
return getLong(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Character getChar(String key, Character defaultValue) {
|
||||
public Character getChar(final String key, final Character defaultValue) {
|
||||
final String value = getStr(key);
|
||||
if (StrUtil.isBlank(value)) {
|
||||
return defaultValue;
|
||||
@@ -377,52 +377,52 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
}
|
||||
|
||||
@Override
|
||||
public Character getChar(String key) {
|
||||
public Character getChar(final String key) {
|
||||
return getChar(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getFloat(String key) {
|
||||
public Float getFloat(final String key) {
|
||||
return getFloat(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float getFloat(String key, Float defaultValue) {
|
||||
public Float getFloat(final String key, final Float defaultValue) {
|
||||
return Convert.toFloat(getStr(key), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getDouble(String key, Double defaultValue) throws NumberFormatException {
|
||||
public Double getDouble(final String key, final Double defaultValue) throws NumberFormatException {
|
||||
return Convert.toDouble(getStr(key), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double getDouble(String key) throws NumberFormatException {
|
||||
public Double getDouble(final String key) throws NumberFormatException {
|
||||
return getDouble(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getShort(String key, Short defaultValue) {
|
||||
public Short getShort(final String key, final Short defaultValue) {
|
||||
return Convert.toShort(getStr(key), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short getShort(String key) {
|
||||
public Short getShort(final String key) {
|
||||
return getShort(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Byte getByte(String key, Byte defaultValue) {
|
||||
public Byte getByte(final String key, final Byte defaultValue) {
|
||||
return Convert.toByte(getStr(key), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Byte getByte(String key) {
|
||||
public Byte getByte(final String key) {
|
||||
return getByte(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getBigDecimal(String key, BigDecimal defaultValue) {
|
||||
public BigDecimal getBigDecimal(final String key, final BigDecimal defaultValue) {
|
||||
final String valueStr = getStr(key);
|
||||
if (StrUtil.isBlank(valueStr)) {
|
||||
return defaultValue;
|
||||
@@ -430,18 +430,18 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
try {
|
||||
return new BigDecimal(valueStr);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getBigDecimal(String key) {
|
||||
public BigDecimal getBigDecimal(final String key) {
|
||||
return getBigDecimal(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getBigInteger(String key, BigInteger defaultValue) {
|
||||
public BigInteger getBigInteger(final String key, final BigInteger defaultValue) {
|
||||
final String valueStr = getStr(key);
|
||||
if (StrUtil.isBlank(valueStr)) {
|
||||
return defaultValue;
|
||||
@@ -449,33 +449,33 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
|
||||
try {
|
||||
return new BigInteger(valueStr);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigInteger getBigInteger(String key) {
|
||||
public BigInteger getBigInteger(final String key) {
|
||||
return getBigInteger(key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends Enum<E>> E getEnum(Class<E> clazz, String key, E defaultValue) {
|
||||
public <E extends Enum<E>> E getEnum(final Class<E> clazz, final String key, final E defaultValue) {
|
||||
return Convert.toEnum(clazz, getStr(key), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <E extends Enum<E>> E getEnum(Class<E> clazz, String key) {
|
||||
public <E extends Enum<E>> E getEnum(final Class<E> clazz, final String key) {
|
||||
return getEnum(clazz, key, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getDate(String key, Date defaultValue) {
|
||||
public Date getDate(final String key, final Date defaultValue) {
|
||||
return Convert.toDate(getStr(key), defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getDate(String key) {
|
||||
public Date getDate(final String key) {
|
||||
return getDate(key, null);
|
||||
}
|
||||
|
||||
@@ -486,9 +486,9 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @return 字符串值
|
||||
* @since 4.1.21
|
||||
*/
|
||||
public String getAndRemoveStr(String... keys) {
|
||||
public String getAndRemoveStr(final String... keys) {
|
||||
Object value = null;
|
||||
for (String key : keys) {
|
||||
for (final String key : keys) {
|
||||
value = remove(key);
|
||||
if (null != value) {
|
||||
break;
|
||||
@@ -526,7 +526,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @return Bean对象
|
||||
* @since 4.6.3
|
||||
*/
|
||||
public <T> T toBean(Class<T> beanClass) {
|
||||
public <T> T toBean(final Class<T> beanClass) {
|
||||
return toBean(beanClass, null);
|
||||
}
|
||||
|
||||
@@ -548,7 +548,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @return Bean对象
|
||||
* @since 4.6.3
|
||||
*/
|
||||
public <T> T toBean(Class<T> beanClass, String prefix) {
|
||||
public <T> T toBean(final Class<T> beanClass, final String prefix) {
|
||||
final T bean = ReflectUtil.newInstanceIfPossible(beanClass);
|
||||
return fillBean(bean, prefix);
|
||||
}
|
||||
@@ -571,11 +571,11 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @return Bean对象
|
||||
* @since 4.6.3
|
||||
*/
|
||||
public <T> T fillBean(T bean, String prefix) {
|
||||
public <T> T fillBean(final T bean, String prefix) {
|
||||
prefix = StrUtil.nullToEmpty(StrUtil.addSuffixIfNot(prefix, StrUtil.DOT));
|
||||
|
||||
String key;
|
||||
for (java.util.Map.Entry<Object, Object> entry : this.entrySet()) {
|
||||
for (final java.util.Map.Entry<Object, Object> entry : this.entrySet()) {
|
||||
key = (String) entry.getKey();
|
||||
if (false == StrUtil.startWith(key, prefix)) {
|
||||
// 非指定开头的属性忽略掉
|
||||
@@ -583,7 +583,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
}
|
||||
try {
|
||||
BeanUtil.setProperty(bean, StrUtil.subSuf(key, prefix.length()), entry.getValue());
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
// 忽略注入失败的字段(这些字段可能用于其它配置)
|
||||
StaticLog.debug("Ignore property: [{}]", key);
|
||||
}
|
||||
@@ -602,7 +602,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param key 属性键
|
||||
* @param value 属性值
|
||||
*/
|
||||
public void setProperty(String key, Object value) {
|
||||
public void setProperty(final String key, final Object value) {
|
||||
super.setProperty(key, value.toString());
|
||||
}
|
||||
|
||||
@@ -612,12 +612,12 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param absolutePath 设置文件的绝对路径
|
||||
* @throws IORuntimeException IO异常,可能为文件未找到
|
||||
*/
|
||||
public void store(String absolutePath) throws IORuntimeException {
|
||||
public void store(final String absolutePath) throws IORuntimeException {
|
||||
Writer writer = null;
|
||||
try {
|
||||
writer = FileUtil.getWriter(absolutePath, charset, false);
|
||||
super.store(writer, null);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new IORuntimeException(e, "Store properties to [{}] error!", absolutePath);
|
||||
} finally {
|
||||
IoUtil.close(writer);
|
||||
@@ -630,7 +630,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
||||
* @param path 相对路径
|
||||
* @param clazz 相对的类
|
||||
*/
|
||||
public void store(String path, Class<?> clazz) {
|
||||
public void store(final String path, final Class<?> clazz) {
|
||||
this.store(FileUtil.getAbsolutePath(path, clazz));
|
||||
}
|
||||
// ----------------------------------------------------------------------- Set end
|
||||
|
@@ -28,7 +28,7 @@ public class PropsUtil {
|
||||
* @param name 文件名,如果没有扩展名,默认为.properties
|
||||
* @return 当前环境下配置文件
|
||||
*/
|
||||
public static Props get(String name) {
|
||||
public static Props get(final String name) {
|
||||
return propsMap.computeIfAbsent(name, (filePath)->{
|
||||
final String extName = FileUtil.extName(filePath);
|
||||
if (StrUtil.isEmpty(extName)) {
|
||||
@@ -46,11 +46,11 @@ public class PropsUtil {
|
||||
*
|
||||
* @return 当前环境下配置文件
|
||||
*/
|
||||
public static Props getFirstFound(String... names) {
|
||||
for (String name : names) {
|
||||
public static Props getFirstFound(final String... names) {
|
||||
for (final String name : names) {
|
||||
try {
|
||||
return get(name);
|
||||
} catch (NoResourceException e) {
|
||||
} catch (final NoResourceException e) {
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ public class GlobalProfile {
|
||||
* @param profile 环境
|
||||
* @return {@link Profile}
|
||||
*/
|
||||
public static Profile setProfile(String profile) {
|
||||
public static Profile setProfile(final String profile) {
|
||||
return Singleton.get(Profile.class, profile);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class GlobalProfile {
|
||||
* @param settingName 配置文件名,可以忽略默认后者(.setting)
|
||||
* @return {@link Setting}
|
||||
*/
|
||||
public static Setting getSetting(String settingName) {
|
||||
public static Setting getSetting(final String settingName) {
|
||||
return Singleton.get(Profile.class).getSetting(settingName);
|
||||
}
|
||||
// -------------------------------------------------------------------------------- Static method end
|
||||
|
@@ -51,7 +51,7 @@ public class Profile implements Serializable {
|
||||
*
|
||||
* @param profile 环境
|
||||
*/
|
||||
public Profile(String profile) {
|
||||
public Profile(final String profile) {
|
||||
this(profile, Setting.DEFAULT_CHARSET, false);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class Profile implements Serializable {
|
||||
* @param charset 编码
|
||||
* @param useVar 是否使用变量
|
||||
*/
|
||||
public Profile(String profile, Charset charset, boolean useVar) {
|
||||
public Profile(final String profile, final Charset charset, final boolean useVar) {
|
||||
this.profile = profile;
|
||||
this.charset = charset;
|
||||
this.useVar = useVar;
|
||||
@@ -75,8 +75,8 @@ public class Profile implements Serializable {
|
||||
* @param name 文件名,如果没有扩展名,默认为.setting
|
||||
* @return 当前环境下配置文件
|
||||
*/
|
||||
public Setting getSetting(String name) {
|
||||
String nameForProfile = fixNameForProfile(name);
|
||||
public Setting getSetting(final String name) {
|
||||
final String nameForProfile = fixNameForProfile(name);
|
||||
Setting setting = settingMap.get(nameForProfile);
|
||||
if (null == setting) {
|
||||
setting = new Setting(nameForProfile, this.charset, this.useVar);
|
||||
@@ -91,7 +91,7 @@ public class Profile implements Serializable {
|
||||
* @param profile 环境
|
||||
* @return 自身
|
||||
*/
|
||||
public Profile setProfile(String profile) {
|
||||
public Profile setProfile(final String profile) {
|
||||
this.profile = profile;
|
||||
return this;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class Profile implements Serializable {
|
||||
* @param charset 编码
|
||||
* @return 自身
|
||||
*/
|
||||
public Profile setCharset(Charset charset) {
|
||||
public Profile setCharset(final Charset charset) {
|
||||
this.charset = charset;
|
||||
return this;
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class Profile implements Serializable {
|
||||
* @param useVar 变量
|
||||
* @return 自身
|
||||
*/
|
||||
public Profile setUseVar(boolean useVar) {
|
||||
public Profile setUseVar(final boolean useVar) {
|
||||
this.useVar = useVar;
|
||||
return this;
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class Profile implements Serializable {
|
||||
* @param name 文件名
|
||||
* @return 修正后的文件名
|
||||
*/
|
||||
private String fixNameForProfile(String name) {
|
||||
private String fixNameForProfile(final String name) {
|
||||
Assert.notBlank(name, "Setting name must be not blank !");
|
||||
final String actralProfile = StrUtil.nullToEmpty(this.profile);
|
||||
if (false == name.contains(StrUtil.DOT)) {
|
||||
|
@@ -25,7 +25,7 @@ public class YamlUtil {
|
||||
* @param path YAML路径,相对路径相对classpath
|
||||
* @return 加载的内容,默认Map
|
||||
*/
|
||||
public static Dict loadByPath(String path) {
|
||||
public static Dict loadByPath(final String path) {
|
||||
return loadByPath(path, Dict.class);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class YamlUtil {
|
||||
* @param type 加载的Bean类型,即转换为的bean
|
||||
* @return 加载的内容,默认Map
|
||||
*/
|
||||
public static <T> T loadByPath(String path, Class<T> type) {
|
||||
public static <T> T loadByPath(final String path, final Class<T> type) {
|
||||
return load(ResourceUtil.getStream(path), type);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class YamlUtil {
|
||||
* @param type 加载的Bean类型,即转换为的bean
|
||||
* @return 加载的内容,默认Map
|
||||
*/
|
||||
public static <T> T load(InputStream in, Class<T> type) {
|
||||
public static <T> T load(final InputStream in, final Class<T> type) {
|
||||
return load(IoUtil.getBomReader(in), type);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class YamlUtil {
|
||||
* @param reader {@link Reader}
|
||||
* @return 加载的Map
|
||||
*/
|
||||
public static Dict load(Reader reader) {
|
||||
public static Dict load(final Reader reader) {
|
||||
return load(reader, Dict.class);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class YamlUtil {
|
||||
* @param type 加载的Bean类型,即转换为的bean
|
||||
* @return 加载的内容,默认Map
|
||||
*/
|
||||
public static <T> T load(Reader reader, Class<T> type) {
|
||||
public static <T> T load(final Reader reader, final Class<T> type) {
|
||||
return load(reader, type, true);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class YamlUtil {
|
||||
* @return 加载的内容,默认Map
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T load(Reader reader, Class<T> type, boolean isCloseReader) {
|
||||
public static <T> T load(final Reader reader, Class<T> type, final boolean isCloseReader) {
|
||||
Assert.notNull(reader, "Reader must be not null !");
|
||||
if (null == type) {
|
||||
type = (Class<T>) Object.class;
|
||||
@@ -107,7 +107,7 @@ public class YamlUtil {
|
||||
* @param object 对象
|
||||
* @param writer {@link Writer}
|
||||
*/
|
||||
public static void dump(Object object, Writer writer) {
|
||||
public static void dump(final Object object, final Writer writer) {
|
||||
final DumperOptions options = new DumperOptions();
|
||||
options.setIndent(2);
|
||||
options.setPrettyFlow(true);
|
||||
@@ -123,7 +123,7 @@ public class YamlUtil {
|
||||
* @param writer {@link Writer}
|
||||
* @param dumperOptions 输出风格
|
||||
*/
|
||||
public static void dump(Object object, Writer writer, DumperOptions dumperOptions) {
|
||||
public static void dump(final Object object, final Writer writer, DumperOptions dumperOptions) {
|
||||
if (null == dumperOptions) {
|
||||
dumperOptions = new DumperOptions();
|
||||
}
|
||||
|
Reference in New Issue
Block a user