mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix code
This commit is contained in:
parent
c72e2bb5ba
commit
d52d36cfdc
@ -164,7 +164,7 @@ public class ZipWriter implements Closeable {
|
|||||||
* @throws IORuntimeException IO异常
|
* @throws IORuntimeException IO异常
|
||||||
*/
|
*/
|
||||||
public ZipWriter add(String path, final InputStream in) throws IORuntimeException {
|
public ZipWriter add(String path, final InputStream in) throws IORuntimeException {
|
||||||
path = StrUtil.nullToEmpty(path);
|
path = StrUtil.emptyIfNull(path);
|
||||||
if (null == in) {
|
if (null == in) {
|
||||||
// 空目录需要检查路径规范性,目录以"/"结尾
|
// 空目录需要检查路径规范性,目录以"/"结尾
|
||||||
path = StrUtil.addSuffixIfNot(path, StrUtil.SLASH);
|
path = StrUtil.addSuffixIfNot(path, StrUtil.SLASH);
|
||||||
|
@ -190,7 +190,7 @@ public class ResourceUtil {
|
|||||||
* @return {@link URL}
|
* @return {@link URL}
|
||||||
*/
|
*/
|
||||||
public static URL getResourceUrl(String resource, final Class<?> baseClass) {
|
public static URL getResourceUrl(String resource, final Class<?> baseClass) {
|
||||||
resource = StrUtil.nullToEmpty(resource);
|
resource = StrUtil.emptyIfNull(resource);
|
||||||
return (null != baseClass) ? baseClass.getResource(resource) : ClassLoaderUtil.getClassLoader().getResource(resource);
|
return (null != baseClass) ? baseClass.getResource(resource) : ClassLoaderUtil.getClassLoader().getResource(resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ public class ClassScanner implements Serializable {
|
|||||||
* @param charset 编码
|
* @param charset 编码
|
||||||
*/
|
*/
|
||||||
public ClassScanner(String packageName, final Predicate<Class<?>> classPredicate, final Charset charset) {
|
public ClassScanner(String packageName, final Predicate<Class<?>> classPredicate, final Charset charset) {
|
||||||
packageName = StrUtil.nullToEmpty(packageName);
|
packageName = StrUtil.emptyIfNull(packageName);
|
||||||
this.packageName = packageName;
|
this.packageName = packageName;
|
||||||
this.packageNameWithDot = StrUtil.addSuffixIfNot(packageName, StrUtil.DOT);
|
this.packageNameWithDot = StrUtil.addSuffixIfNot(packageName, StrUtil.DOT);
|
||||||
this.packageDirName = packageName.replace(CharUtil.DOT, File.separatorChar);
|
this.packageDirName = packageName.replace(CharUtil.DOT, File.separatorChar);
|
||||||
|
328
hutool-core/src/main/java/cn/hutool/core/map/MapGetUtil.java
Executable file
328
hutool-core/src/main/java/cn/hutool/core/map/MapGetUtil.java
Executable file
@ -0,0 +1,328 @@
|
|||||||
|
package cn.hutool.core.map;
|
||||||
|
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import cn.hutool.core.reflect.TypeReference;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map的getXXX封装,提供针对通用型的value按照所需类型获取值
|
||||||
|
*
|
||||||
|
* @author looly
|
||||||
|
* @since 6.0.0
|
||||||
|
*/
|
||||||
|
public class MapGetUtil {
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为字符串
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
* @since 4.0.6
|
||||||
|
*/
|
||||||
|
public static String getStr(final Map<?, ?> map, final Object key) {
|
||||||
|
return get(map, key, String.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为字符串
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.3.11
|
||||||
|
*/
|
||||||
|
public static String getStr(final Map<?, ?> map, final Object key, final String defaultValue) {
|
||||||
|
return get(map, key, String.class, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Integer
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
* @since 4.0.6
|
||||||
|
*/
|
||||||
|
public static Integer getInt(final Map<?, ?> map, final Object key) {
|
||||||
|
return get(map, key, Integer.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Integer
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.3.11
|
||||||
|
*/
|
||||||
|
public static Integer getInt(final Map<?, ?> map, final Object key, final Integer defaultValue) {
|
||||||
|
return get(map, key, Integer.class, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Double
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
* @since 4.0.6
|
||||||
|
*/
|
||||||
|
public static Double getDouble(final Map<?, ?> map, final Object key) {
|
||||||
|
return get(map, key, Double.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Double
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.3.11
|
||||||
|
*/
|
||||||
|
public static Double getDouble(final Map<?, ?> map, final Object key, final Double defaultValue) {
|
||||||
|
return get(map, key, Double.class, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Float
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
* @since 4.0.6
|
||||||
|
*/
|
||||||
|
public static Float getFloat(final Map<?, ?> map, final Object key) {
|
||||||
|
return get(map, key, Float.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Float
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.3.11
|
||||||
|
*/
|
||||||
|
public static Float getFloat(final Map<?, ?> map, final Object key, final Float defaultValue) {
|
||||||
|
return get(map, key, Float.class, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Short
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
* @since 4.0.6
|
||||||
|
*/
|
||||||
|
public static Short getShort(final Map<?, ?> map, final Object key) {
|
||||||
|
return get(map, key, Short.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Short
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.3.11
|
||||||
|
*/
|
||||||
|
public static Short getShort(final Map<?, ?> map, final Object key, final Short defaultValue) {
|
||||||
|
return get(map, key, Short.class, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Bool
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
* @since 4.0.6
|
||||||
|
*/
|
||||||
|
public static Boolean getBool(final Map<?, ?> map, final Object key) {
|
||||||
|
return get(map, key, Boolean.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Bool
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.3.11
|
||||||
|
*/
|
||||||
|
public static Boolean getBool(final Map<?, ?> map, final Object key, final Boolean defaultValue) {
|
||||||
|
return get(map, key, Boolean.class, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Character
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
* @since 4.0.6
|
||||||
|
*/
|
||||||
|
public static Character getChar(final Map<?, ?> map, final Object key) {
|
||||||
|
return get(map, key, Character.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Character
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.3.11
|
||||||
|
*/
|
||||||
|
public static Character getChar(final Map<?, ?> map, final Object key, final Character defaultValue) {
|
||||||
|
return get(map, key, Character.class, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Long
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
* @since 4.0.6
|
||||||
|
*/
|
||||||
|
public static Long getLong(final Map<?, ?> map, final Object key) {
|
||||||
|
return get(map, key, Long.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为Long
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.3.11
|
||||||
|
*/
|
||||||
|
public static Long getLong(final Map<?, ?> map, final Object key, final Long defaultValue) {
|
||||||
|
return get(map, key, Long.class, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为{@link Date}
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
* @since 4.1.2
|
||||||
|
*/
|
||||||
|
public static Date getDate(final Map<?, ?> map, final Object key) {
|
||||||
|
return get(map, key, Date.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为{@link Date}
|
||||||
|
*
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 4.1.2
|
||||||
|
*/
|
||||||
|
public static Date getDate(final Map<?, ?> map, final Object key, final Date defaultValue) {
|
||||||
|
return get(map, key, Date.class, defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为指定类型
|
||||||
|
*
|
||||||
|
* @param <T> 目标值类型
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param type 值类型
|
||||||
|
* @return 值
|
||||||
|
* @since 4.0.6
|
||||||
|
*/
|
||||||
|
public static <T> T get(final Map<?, ?> map, final Object key, final Class<T> type) {
|
||||||
|
return get(map, key, type, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为指定类型
|
||||||
|
*
|
||||||
|
* @param <T> 目标值类型
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param type 值类型
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.3.11
|
||||||
|
*/
|
||||||
|
public static <T> T get(final Map<?, ?> map, final Object key, final Class<T> type, final T defaultValue) {
|
||||||
|
return null == map ? defaultValue : Convert.convert(type, map.get(key), defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为指定类型,此方法在转换失败后不抛异常,返回null。
|
||||||
|
*
|
||||||
|
* @param <T> 目标值类型
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param type 值类型
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.5.3
|
||||||
|
*/
|
||||||
|
public static <T> T getQuietly(final Map<?, ?> map, final Object key, final Class<T> type, final T defaultValue) {
|
||||||
|
return null == map ? defaultValue : Convert.convertQuietly(type, map.get(key), defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为指定类型
|
||||||
|
*
|
||||||
|
* @param <T> 目标值类型
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param type 值类型
|
||||||
|
* @return 值
|
||||||
|
* @since 4.5.12
|
||||||
|
*/
|
||||||
|
public static <T> T get(final Map<?, ?> map, final Object key, final TypeReference<T> type) {
|
||||||
|
return get(map, key, type, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为指定类型
|
||||||
|
*
|
||||||
|
* @param <T> 目标值类型
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param type 值类型
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.3.11
|
||||||
|
*/
|
||||||
|
public static <T> T get(final Map<?, ?> map, final Object key, final TypeReference<T> type, final T defaultValue) {
|
||||||
|
return null == map ? defaultValue : Convert.convert(type, map.get(key), defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Map指定key的值,并转换为指定类型,转换失败后返回null,不抛异常
|
||||||
|
*
|
||||||
|
* @param <T> 目标值类型
|
||||||
|
* @param map Map
|
||||||
|
* @param key 键
|
||||||
|
* @param type 值类型
|
||||||
|
* @param defaultValue 默认值
|
||||||
|
* @return 值
|
||||||
|
* @since 5.5.3
|
||||||
|
*/
|
||||||
|
public static <T> T getQuietly(final Map<?, ?> map, final Object key, final TypeReference<T> type, final T defaultValue) {
|
||||||
|
return null == map ? defaultValue : Convert.convertQuietly(type, map.get(key), defaultValue);
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,6 @@ import cn.hutool.core.collection.iter.IterUtil;
|
|||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.exceptions.UtilException;
|
import cn.hutool.core.exceptions.UtilException;
|
||||||
import cn.hutool.core.reflect.ConstructorUtil;
|
import cn.hutool.core.reflect.ConstructorUtil;
|
||||||
import cn.hutool.core.reflect.TypeReference;
|
|
||||||
import cn.hutool.core.text.StrUtil;
|
import cn.hutool.core.text.StrUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
import cn.hutool.core.util.ObjUtil;
|
||||||
@ -16,7 +15,6 @@ import java.util.AbstractMap;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -25,7 +23,6 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.NavigableMap;
|
import java.util.NavigableMap;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.SortedMap;
|
import java.util.SortedMap;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@ -41,7 +38,7 @@ import java.util.stream.Collectors;
|
|||||||
* @author Looly
|
* @author Looly
|
||||||
* @since 3.1.1
|
* @since 3.1.1
|
||||||
*/
|
*/
|
||||||
public class MapUtil {
|
public class MapUtil extends MapGetUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认初始大小
|
* 默认初始大小
|
||||||
@ -250,9 +247,9 @@ public class MapUtil {
|
|||||||
if (null == mapType || mapType.isAssignableFrom(AbstractMap.class)) {
|
if (null == mapType || mapType.isAssignableFrom(AbstractMap.class)) {
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
} else {
|
} else {
|
||||||
try{
|
try {
|
||||||
return (Map<K, V>) ConstructorUtil.newInstance(mapType);
|
return (Map<K, V>) ConstructorUtil.newInstance(mapType);
|
||||||
}catch (UtilException e){
|
} catch (final UtilException e) {
|
||||||
// 不支持的map类型,返回默认的HashMap
|
// 不支持的map类型,返回默认的HashMap
|
||||||
return new HashMap<>();
|
return new HashMap<>();
|
||||||
}
|
}
|
||||||
@ -483,14 +480,14 @@ public class MapUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final List<Map<K, V>> resultList = new ArrayList<>();
|
final List<Map<K, V>> resultList = new ArrayList<>();
|
||||||
for (Entry<K, ? extends Iterable<V>> entry : listMap.entrySet()) {
|
for (final Entry<K, ? extends Iterable<V>> entry : listMap.entrySet()) {
|
||||||
final Iterator<V> iterator = IterUtil.getIter(entry.getValue());
|
final Iterator<V> iterator = IterUtil.getIter(entry.getValue());
|
||||||
if (IterUtil.isEmpty(iterator)) {
|
if (IterUtil.isEmpty(iterator)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final K key = entry.getKey();
|
final K key = entry.getKey();
|
||||||
// 对已经存在的map添加元素
|
// 对已经存在的map添加元素
|
||||||
for (Map<K, V> map : resultList) {
|
for (final Map<K, V> map : resultList) {
|
||||||
// 还可以继续添加元素
|
// 还可以继续添加元素
|
||||||
if (iterator.hasNext()) {
|
if (iterator.hasNext()) {
|
||||||
map.put(key, iterator.next());
|
map.put(key, iterator.next());
|
||||||
@ -966,319 +963,6 @@ public class MapUtil {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为字符串
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @return 值
|
|
||||||
* @since 4.0.6
|
|
||||||
*/
|
|
||||||
public static String getStr(final Map<?, ?> map, final Object key) {
|
|
||||||
return get(map, key, String.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为字符串
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.3.11
|
|
||||||
*/
|
|
||||||
public static String getStr(final Map<?, ?> map, final Object key, final String defaultValue) {
|
|
||||||
return get(map, key, String.class, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Integer
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @return 值
|
|
||||||
* @since 4.0.6
|
|
||||||
*/
|
|
||||||
public static Integer getInt(final Map<?, ?> map, final Object key) {
|
|
||||||
return get(map, key, Integer.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Integer
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.3.11
|
|
||||||
*/
|
|
||||||
public static Integer getInt(final Map<?, ?> map, final Object key, final Integer defaultValue) {
|
|
||||||
return get(map, key, Integer.class, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Double
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @return 值
|
|
||||||
* @since 4.0.6
|
|
||||||
*/
|
|
||||||
public static Double getDouble(final Map<?, ?> map, final Object key) {
|
|
||||||
return get(map, key, Double.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Double
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.3.11
|
|
||||||
*/
|
|
||||||
public static Double getDouble(final Map<?, ?> map, final Object key, final Double defaultValue) {
|
|
||||||
return get(map, key, Double.class, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Float
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @return 值
|
|
||||||
* @since 4.0.6
|
|
||||||
*/
|
|
||||||
public static Float getFloat(final Map<?, ?> map, final Object key) {
|
|
||||||
return get(map, key, Float.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Float
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.3.11
|
|
||||||
*/
|
|
||||||
public static Float getFloat(final Map<?, ?> map, final Object key, final Float defaultValue) {
|
|
||||||
return get(map, key, Float.class, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Short
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @return 值
|
|
||||||
* @since 4.0.6
|
|
||||||
*/
|
|
||||||
public static Short getShort(final Map<?, ?> map, final Object key) {
|
|
||||||
return get(map, key, Short.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Short
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.3.11
|
|
||||||
*/
|
|
||||||
public static Short getShort(final Map<?, ?> map, final Object key, final Short defaultValue) {
|
|
||||||
return get(map, key, Short.class, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Bool
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @return 值
|
|
||||||
* @since 4.0.6
|
|
||||||
*/
|
|
||||||
public static Boolean getBool(final Map<?, ?> map, final Object key) {
|
|
||||||
return get(map, key, Boolean.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Bool
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.3.11
|
|
||||||
*/
|
|
||||||
public static Boolean getBool(final Map<?, ?> map, final Object key, final Boolean defaultValue) {
|
|
||||||
return get(map, key, Boolean.class, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Character
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @return 值
|
|
||||||
* @since 4.0.6
|
|
||||||
*/
|
|
||||||
public static Character getChar(final Map<?, ?> map, final Object key) {
|
|
||||||
return get(map, key, Character.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Character
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.3.11
|
|
||||||
*/
|
|
||||||
public static Character getChar(final Map<?, ?> map, final Object key, final Character defaultValue) {
|
|
||||||
return get(map, key, Character.class, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Long
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @return 值
|
|
||||||
* @since 4.0.6
|
|
||||||
*/
|
|
||||||
public static Long getLong(final Map<?, ?> map, final Object key) {
|
|
||||||
return get(map, key, Long.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为Long
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.3.11
|
|
||||||
*/
|
|
||||||
public static Long getLong(final Map<?, ?> map, final Object key, final Long defaultValue) {
|
|
||||||
return get(map, key, Long.class, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为{@link Date}
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @return 值
|
|
||||||
* @since 4.1.2
|
|
||||||
*/
|
|
||||||
public static Date getDate(final Map<?, ?> map, final Object key) {
|
|
||||||
return get(map, key, Date.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为{@link Date}
|
|
||||||
*
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 4.1.2
|
|
||||||
*/
|
|
||||||
public static Date getDate(final Map<?, ?> map, final Object key, final Date defaultValue) {
|
|
||||||
return get(map, key, Date.class, defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为指定类型
|
|
||||||
*
|
|
||||||
* @param <T> 目标值类型
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param type 值类型
|
|
||||||
* @return 值
|
|
||||||
* @since 4.0.6
|
|
||||||
*/
|
|
||||||
public static <T> T get(final Map<?, ?> map, final Object key, final Class<T> type) {
|
|
||||||
return get(map, key, type, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为指定类型
|
|
||||||
*
|
|
||||||
* @param <T> 目标值类型
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param type 值类型
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.3.11
|
|
||||||
*/
|
|
||||||
public static <T> T get(final Map<?, ?> map, final Object key, final Class<T> type, final T defaultValue) {
|
|
||||||
return null == map ? defaultValue : Convert.convert(type, map.get(key), defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为指定类型,此方法在转换失败后不抛异常,返回null。
|
|
||||||
*
|
|
||||||
* @param <T> 目标值类型
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param type 值类型
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.5.3
|
|
||||||
*/
|
|
||||||
public static <T> T getQuietly(final Map<?, ?> map, final Object key, final Class<T> type, final T defaultValue) {
|
|
||||||
return null == map ? defaultValue : Convert.convertQuietly(type, map.get(key), defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为指定类型
|
|
||||||
*
|
|
||||||
* @param <T> 目标值类型
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param type 值类型
|
|
||||||
* @return 值
|
|
||||||
* @since 4.5.12
|
|
||||||
*/
|
|
||||||
public static <T> T get(final Map<?, ?> map, final Object key, final TypeReference<T> type) {
|
|
||||||
return get(map, key, type, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为指定类型
|
|
||||||
*
|
|
||||||
* @param <T> 目标值类型
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param type 值类型
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.3.11
|
|
||||||
*/
|
|
||||||
public static <T> T get(final Map<?, ?> map, final Object key, final TypeReference<T> type, final T defaultValue) {
|
|
||||||
return null == map ? defaultValue : Convert.convert(type, map.get(key), defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取Map指定key的值,并转换为指定类型,转换失败后返回null,不抛异常
|
|
||||||
*
|
|
||||||
* @param <T> 目标值类型
|
|
||||||
* @param map Map
|
|
||||||
* @param key 键
|
|
||||||
* @param type 值类型
|
|
||||||
* @param defaultValue 默认值
|
|
||||||
* @return 值
|
|
||||||
* @since 5.5.3
|
|
||||||
*/
|
|
||||||
public static <T> T getQuietly(final Map<?, ?> map, final Object key, final TypeReference<T> type, final T defaultValue) {
|
|
||||||
return null == map ? defaultValue : Convert.convertQuietly(type, map.get(key), defaultValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重命名键<br>
|
* 重命名键<br>
|
||||||
* 实现方式为一处然后重新put,当旧的key不存在直接返回<br>
|
* 实现方式为一处然后重新put,当旧的key不存在直接返回<br>
|
||||||
@ -1557,4 +1241,32 @@ public class MapUtil {
|
|||||||
}
|
}
|
||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据给定的entry列表,根据entry的key进行分组;
|
||||||
|
*
|
||||||
|
* @param <K> 键类型
|
||||||
|
* @param <V> 值类型
|
||||||
|
* @param entries entry列表
|
||||||
|
* @return entries
|
||||||
|
* @since 5.8.6
|
||||||
|
*/
|
||||||
|
public static <K, V> Map<K, List<V>> grouping(final Iterable<Map.Entry<K, V>> entries) {
|
||||||
|
if (CollUtil.isEmpty(entries)) {
|
||||||
|
return zero();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Map<K, List<V>> map = new HashMap<>();
|
||||||
|
for (final Map.Entry<K, V> pair : entries) {
|
||||||
|
final List<V> values;
|
||||||
|
if (map.containsKey(pair.getKey())) {
|
||||||
|
values = map.get(pair.getKey());
|
||||||
|
} else {
|
||||||
|
values = ListUtil.of();
|
||||||
|
map.put(pair.getKey(), values);
|
||||||
|
}
|
||||||
|
values.add(pair.getValue());
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -579,7 +579,7 @@ public class URLUtil {
|
|||||||
if (isEncodePath) {
|
if (isEncodePath) {
|
||||||
path = RFC3986.PATH.encode(path, CharsetUtil.UTF_8);
|
path = RFC3986.PATH.encode(path, CharsetUtil.UTF_8);
|
||||||
}
|
}
|
||||||
return protocol + domain + StrUtil.nullToEmpty(path) + StrUtil.nullToEmpty(params);
|
return protocol + domain + StrUtil.emptyIfNull(path) + StrUtil.emptyIfNull(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -406,7 +406,7 @@ public class UrlQuery {
|
|||||||
private void addParam(final String key, final String value, final Charset charset) {
|
private void addParam(final String key, final String value, final Charset charset) {
|
||||||
if (null != key) {
|
if (null != key) {
|
||||||
final String actualKey = URLDecoder.decode(key, charset, isFormUrlEncoded);
|
final String actualKey = URLDecoder.decode(key, charset, isFormUrlEncoded);
|
||||||
this.query.put(actualKey, StrUtil.nullToEmpty(URLDecoder.decode(value, charset, isFormUrlEncoded)));
|
this.query.put(actualKey, StrUtil.emptyIfNull(URLDecoder.decode(value, charset, isFormUrlEncoded)));
|
||||||
} else if (null != value) {
|
} else if (null != value) {
|
||||||
// name为空,value作为name,value赋值null
|
// name为空,value作为name,value赋值null
|
||||||
this.query.put(URLDecoder.decode(value, charset, isFormUrlEncoded), null);
|
this.query.put(URLDecoder.decode(value, charset, isFormUrlEncoded), null);
|
||||||
|
@ -50,7 +50,7 @@ public class CharSequenceUtil extends StrChecker {
|
|||||||
* @param str 被转换的字符串
|
* @param str 被转换的字符串
|
||||||
* @return 转换后的字符串
|
* @return 转换后的字符串
|
||||||
*/
|
*/
|
||||||
public static String nullToEmpty(final CharSequence str) {
|
public static String emptyIfNull(final CharSequence str) {
|
||||||
return ObjUtil.defaultIfNull(str, EMPTY).toString();
|
return ObjUtil.defaultIfNull(str, EMPTY).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ public class CharSequenceUtil extends StrChecker {
|
|||||||
* @param str 被转换的字符串
|
* @param str 被转换的字符串
|
||||||
* @return 转换后的字符串
|
* @return 转换后的字符串
|
||||||
*/
|
*/
|
||||||
public static <T extends CharSequence> T emptyToNull(final T str) {
|
public static <T extends CharSequence> T nullIfEmpty(final T str) {
|
||||||
return isEmpty(str) ? null : str;
|
return isEmpty(str) ? null : str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -809,10 +809,10 @@ public class CharSequenceUtil extends StrChecker {
|
|||||||
/**
|
/**
|
||||||
* 指定范围内查找指定字符
|
* 指定范围内查找指定字符
|
||||||
*
|
*
|
||||||
* @param text 字符串
|
* @param text 字符串
|
||||||
* @param matcher 被查找的字符匹配器
|
* @param matcher 被查找的字符匹配器
|
||||||
* @param start 起始位置,如果小于0,从0开始查找
|
* @param start 起始位置,如果小于0,从0开始查找
|
||||||
* @param end 终止位置,如果超过str.length()则默认查找到字符串末尾
|
* @param end 终止位置,如果超过str.length()则默认查找到字符串末尾
|
||||||
* @return 位置
|
* @return 位置
|
||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
*/
|
*/
|
||||||
@ -2521,7 +2521,7 @@ public class CharSequenceUtil extends StrChecker {
|
|||||||
* @return 包装后的字符串
|
* @return 包装后的字符串
|
||||||
*/
|
*/
|
||||||
public static String wrap(final CharSequence str, final CharSequence prefix, final CharSequence suffix) {
|
public static String wrap(final CharSequence str, final CharSequence prefix, final CharSequence suffix) {
|
||||||
return nullToEmpty(prefix).concat(nullToEmpty(str)).concat(nullToEmpty(suffix));
|
return emptyIfNull(prefix).concat(emptyIfNull(str)).concat(emptyIfNull(suffix));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3990,7 +3990,7 @@ public class CharSequenceUtil extends StrChecker {
|
|||||||
public static String concat(final boolean isNullToEmpty, final CharSequence... strs) {
|
public static String concat(final boolean isNullToEmpty, final CharSequence... strs) {
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for (final CharSequence str : strs) {
|
for (final CharSequence str : strs) {
|
||||||
sb.append(isNullToEmpty ? nullToEmpty(str) : str);
|
sb.append(isNullToEmpty ? emptyIfNull(str) : str);
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ public enum GlobalHeaders {
|
|||||||
for (final Entry<String, List<String>> entry : headers.entrySet()) {
|
for (final Entry<String, List<String>> entry : headers.entrySet()) {
|
||||||
name = entry.getKey();
|
name = entry.getKey();
|
||||||
for (final String value : entry.getValue()) {
|
for (final String value : entry.getValue()) {
|
||||||
this.header(name, StrUtil.nullToEmpty(value), false);
|
this.header(name, StrUtil.emptyIfNull(value), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
|
@ -174,7 +174,7 @@ public abstract class HttpBase<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final Entry<String, String> entry : headers.entrySet()) {
|
for (final Entry<String, String> entry : headers.entrySet()) {
|
||||||
this.header(entry.getKey(), StrUtil.nullToEmpty(entry.getValue()), isOverride);
|
this.header(entry.getKey(), StrUtil.emptyIfNull(entry.getValue()), isOverride);
|
||||||
}
|
}
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ public abstract class HttpBase<T> {
|
|||||||
for (final Entry<String, List<String>> entry : headers.entrySet()) {
|
for (final Entry<String, List<String>> entry : headers.entrySet()) {
|
||||||
name = entry.getKey();
|
name = entry.getKey();
|
||||||
for (final String value : entry.getValue()) {
|
for (final String value : entry.getValue()) {
|
||||||
this.header(name, StrUtil.nullToEmpty(value), isOverride);
|
this.header(name, StrUtil.emptyIfNull(value), isOverride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (T) this;
|
return (T) this;
|
||||||
@ -227,7 +227,7 @@ public abstract class HttpBase<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (final Entry<String, String> entry : headers.entrySet()) {
|
for (final Entry<String, String> entry : headers.entrySet()) {
|
||||||
this.header(entry.getKey(), StrUtil.nullToEmpty(entry.getValue()), false);
|
this.header(entry.getKey(), StrUtil.emptyIfNull(entry.getValue()), false);
|
||||||
}
|
}
|
||||||
return (T) this;
|
return (T) this;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ public class HttpConnection {
|
|||||||
for (final Entry<String, List<String>> entry : headerMap.entrySet()) {
|
for (final Entry<String, List<String>> entry : headerMap.entrySet()) {
|
||||||
name = entry.getKey();
|
name = entry.getKey();
|
||||||
for (final String value : entry.getValue()) {
|
for (final String value : entry.getValue()) {
|
||||||
this.header(name, StrUtil.nullToEmpty(value), isOverride);
|
this.header(name, StrUtil.emptyIfNull(value), isOverride);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -449,7 +449,7 @@ public class CellUtil {
|
|||||||
}
|
}
|
||||||
final Comment comment = drawing.createCellComment(anchor);
|
final Comment comment = drawing.createCellComment(anchor);
|
||||||
comment.setString(factory.createRichTextString(commentText));
|
comment.setString(factory.createRichTextString(commentText));
|
||||||
comment.setAuthor(StrUtil.nullToEmpty(commentAuthor));
|
comment.setAuthor(StrUtil.emptyIfNull(commentAuthor));
|
||||||
cell.setCellComment(comment);
|
cell.setCellComment(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
|||||||
public String get(final String group, final String key) {
|
public String get(final String group, final String key) {
|
||||||
readLock.lock();
|
readLock.lock();
|
||||||
try {
|
try {
|
||||||
final LinkedHashMap<String, String> map = this.get(StrUtil.nullToEmpty(group));
|
final LinkedHashMap<String, String> map = this.get(StrUtil.emptyIfNull(group));
|
||||||
if (MapUtil.isNotEmpty(map)) {
|
if (MapUtil.isNotEmpty(map)) {
|
||||||
return map.get(key);
|
return map.get(key);
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
|||||||
* @return 此key之前存在的值,如果没有返回null
|
* @return 此key之前存在的值,如果没有返回null
|
||||||
*/
|
*/
|
||||||
public String put(String group, final String key, final String value) {
|
public String put(String group, final String key, final String value) {
|
||||||
group = StrUtil.nullToEmpty(group).trim();
|
group = StrUtil.emptyIfNull(group).trim();
|
||||||
writeLock.lock();
|
writeLock.lock();
|
||||||
try {
|
try {
|
||||||
final LinkedHashMap<String, String> valueMap = this.computeIfAbsent(group, k -> new LinkedHashMap<>());
|
final LinkedHashMap<String, String> valueMap = this.computeIfAbsent(group, k -> new LinkedHashMap<>());
|
||||||
@ -121,7 +121,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
|||||||
* @return 被删除的值,如果值不存在,返回null
|
* @return 被删除的值,如果值不存在,返回null
|
||||||
*/
|
*/
|
||||||
public String remove(String group, final String key) {
|
public String remove(String group, final String key) {
|
||||||
group = StrUtil.nullToEmpty(group).trim();
|
group = StrUtil.emptyIfNull(group).trim();
|
||||||
writeLock.lock();
|
writeLock.lock();
|
||||||
try {
|
try {
|
||||||
final LinkedHashMap<String, String> valueMap = this.get(group);
|
final LinkedHashMap<String, String> valueMap = this.get(group);
|
||||||
@ -141,7 +141,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
|||||||
* @return 是否为空
|
* @return 是否为空
|
||||||
*/
|
*/
|
||||||
public boolean isEmpty(String group) {
|
public boolean isEmpty(String group) {
|
||||||
group = StrUtil.nullToEmpty(group).trim();
|
group = StrUtil.emptyIfNull(group).trim();
|
||||||
readLock.lock();
|
readLock.lock();
|
||||||
try {
|
try {
|
||||||
final LinkedHashMap<String, String> valueMap = this.get(group);
|
final LinkedHashMap<String, String> valueMap = this.get(group);
|
||||||
@ -172,7 +172,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
|||||||
* @return 是否包含key
|
* @return 是否包含key
|
||||||
*/
|
*/
|
||||||
public boolean containsKey(String group, final String key) {
|
public boolean containsKey(String group, final String key) {
|
||||||
group = StrUtil.nullToEmpty(group).trim();
|
group = StrUtil.emptyIfNull(group).trim();
|
||||||
readLock.lock();
|
readLock.lock();
|
||||||
try {
|
try {
|
||||||
final LinkedHashMap<String, String> valueMap = this.get(group);
|
final LinkedHashMap<String, String> valueMap = this.get(group);
|
||||||
@ -193,7 +193,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
|||||||
* @return 是否包含值
|
* @return 是否包含值
|
||||||
*/
|
*/
|
||||||
public boolean containsValue(String group, final String value) {
|
public boolean containsValue(String group, final String value) {
|
||||||
group = StrUtil.nullToEmpty(group).trim();
|
group = StrUtil.emptyIfNull(group).trim();
|
||||||
readLock.lock();
|
readLock.lock();
|
||||||
try {
|
try {
|
||||||
final LinkedHashMap<String, String> valueMap = this.get(group);
|
final LinkedHashMap<String, String> valueMap = this.get(group);
|
||||||
@ -213,7 +213,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
|||||||
* @return this
|
* @return this
|
||||||
*/
|
*/
|
||||||
public GroupedMap clear(String group) {
|
public GroupedMap clear(String group) {
|
||||||
group = StrUtil.nullToEmpty(group).trim();
|
group = StrUtil.emptyIfNull(group).trim();
|
||||||
writeLock.lock();
|
writeLock.lock();
|
||||||
try {
|
try {
|
||||||
final LinkedHashMap<String, String> valueMap = this.get(group);
|
final LinkedHashMap<String, String> valueMap = this.get(group);
|
||||||
@ -243,7 +243,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
|||||||
* @return 键Set
|
* @return 键Set
|
||||||
*/
|
*/
|
||||||
public Set<String> keySet(String group) {
|
public Set<String> keySet(String group) {
|
||||||
group = StrUtil.nullToEmpty(group).trim();
|
group = StrUtil.emptyIfNull(group).trim();
|
||||||
readLock.lock();
|
readLock.lock();
|
||||||
try {
|
try {
|
||||||
final LinkedHashMap<String, String> valueMap = this.get(group);
|
final LinkedHashMap<String, String> valueMap = this.get(group);
|
||||||
@ -263,7 +263,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
|||||||
* @return 值
|
* @return 值
|
||||||
*/
|
*/
|
||||||
public Collection<String> values(String group) {
|
public Collection<String> values(String group) {
|
||||||
group = StrUtil.nullToEmpty(group).trim();
|
group = StrUtil.emptyIfNull(group).trim();
|
||||||
readLock.lock();
|
readLock.lock();
|
||||||
try {
|
try {
|
||||||
final LinkedHashMap<String, String> valueMap = this.get(group);
|
final LinkedHashMap<String, String> valueMap = this.get(group);
|
||||||
@ -293,7 +293,7 @@ public class GroupedMap extends LinkedHashMap<String, LinkedHashMap<String, Stri
|
|||||||
* @return 键值对
|
* @return 键值对
|
||||||
*/
|
*/
|
||||||
public Set<Entry<String, String>> entrySet(String group) {
|
public Set<Entry<String, String>> entrySet(String group) {
|
||||||
group = StrUtil.nullToEmpty(group).trim();
|
group = StrUtil.emptyIfNull(group).trim();
|
||||||
readLock.lock();
|
readLock.lock();
|
||||||
try {
|
try {
|
||||||
final LinkedHashMap<String, String> valueMap = this.get(group);
|
final LinkedHashMap<String, String> valueMap = this.get(group);
|
||||||
|
@ -572,7 +572,7 @@ public final class Props extends Properties implements BasicTypeGetter<String>,
|
|||||||
* @since 4.6.3
|
* @since 4.6.3
|
||||||
*/
|
*/
|
||||||
public <T> T fillBean(final T bean, String prefix) {
|
public <T> T fillBean(final T bean, String prefix) {
|
||||||
prefix = StrUtil.nullToEmpty(StrUtil.addSuffixIfNot(prefix, StrUtil.DOT));
|
prefix = StrUtil.emptyIfNull(StrUtil.addSuffixIfNot(prefix, StrUtil.DOT));
|
||||||
|
|
||||||
String key;
|
String key;
|
||||||
for (final java.util.Map.Entry<Object, Object> entry : this.entrySet()) {
|
for (final java.util.Map.Entry<Object, Object> entry : this.entrySet()) {
|
||||||
|
@ -137,7 +137,7 @@ public class Profile implements Serializable {
|
|||||||
*/
|
*/
|
||||||
private String fixNameForProfile(final String name) {
|
private String fixNameForProfile(final String name) {
|
||||||
Assert.notBlank(name, "Setting name must be not blank !");
|
Assert.notBlank(name, "Setting name must be not blank !");
|
||||||
final String actralProfile = StrUtil.nullToEmpty(this.profile);
|
final String actralProfile = StrUtil.emptyIfNull(this.profile);
|
||||||
if (false == name.contains(StrUtil.DOT)) {
|
if (false == name.contains(StrUtil.DOT)) {
|
||||||
return StrUtil.format("{}/{}.setting", actralProfile, name);
|
return StrUtil.format("{}/{}.setting", actralProfile, name);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user