mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add method
This commit is contained in:
parent
30695b906b
commit
1b90832f91
@ -10,6 +10,7 @@
|
|||||||
* 【core 】 NumberUtil.toStr修改逻辑,去掉BigDecimal的科学计数表示(pr#196@Gitee)
|
* 【core 】 NumberUtil.toStr修改逻辑,去掉BigDecimal的科学计数表示(pr#196@Gitee)
|
||||||
* 【core 】 ListUtil.page第一页页码使用PageUtil(pr#198@Gitee)
|
* 【core 】 ListUtil.page第一页页码使用PageUtil(pr#198@Gitee)
|
||||||
* 【http 】 增加微信、企业微信ua识别(pr#1179@Github)
|
* 【http 】 增加微信、企业微信ua识别(pr#1179@Github)
|
||||||
|
* 【core 】 ObjectUtil增加defaultIfXXX(pr#199@Gitee)
|
||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
* 【core 】 修复ChineseDate没有忽略时分秒导致计算错误问题(issue#I1YW12@Gitee)
|
* 【core 】 修复ChineseDate没有忽略时分秒导致计算错误问题(issue#I1YW12@Gitee)
|
||||||
@ -17,6 +18,7 @@
|
|||||||
* 【core 】 修复BeanDesc读取父类属性覆盖子类属性导致的问题(pr#1175@Github)
|
* 【core 】 修复BeanDesc读取父类属性覆盖子类属性导致的问题(pr#1175@Github)
|
||||||
* 【aop 】 修复SimpleAspect一个重载导致的问题,去掉重载的after方法(issue#I1YUG9@Gitee)
|
* 【aop 】 修复SimpleAspect一个重载导致的问题,去掉重载的after方法(issue#I1YUG9@Gitee)
|
||||||
* 【poi 】 修复03 sax读取日期问题(issue#I1Z83N@Gitee)
|
* 【poi 】 修复03 sax读取日期问题(issue#I1Z83N@Gitee)
|
||||||
|
* 【core 】 修复FileUtil.size软链导致的问题(pr#200@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -511,7 +511,7 @@ public class FileUtil extends PathUtil {
|
|||||||
* @return 总大小,bytes长度
|
* @return 总大小,bytes长度
|
||||||
*/
|
*/
|
||||||
public static long size(File file) {
|
public static long size(File file) {
|
||||||
if (null == file || false == file.exists() || FileUtil.isSymlink(file)) {
|
if (null == file || false == file.exists() || isSymlink(file)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import cn.hutool.core.util.ReUtil;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 常用正则表达式集合
|
* 常用正则表达式集合,更多正则见:https://any86.github.io/any-rule/
|
||||||
*
|
*
|
||||||
* @author Looly
|
* @author Looly
|
||||||
*/
|
*/
|
||||||
|
@ -62,8 +62,8 @@ public class ObjectUtil {
|
|||||||
* @see Objects#equals(Object, Object)
|
* @see Objects#equals(Object, Object)
|
||||||
*/
|
*/
|
||||||
public static boolean equal(Object obj1, Object obj2) {
|
public static boolean equal(Object obj1, Object obj2) {
|
||||||
if(obj1 instanceof BigDecimal && obj2 instanceof BigDecimal){
|
if (obj1 instanceof BigDecimal && obj2 instanceof BigDecimal) {
|
||||||
return NumberUtil.equals((BigDecimal)obj1, (BigDecimal)obj2);
|
return NumberUtil.equals((BigDecimal) obj1, (BigDecimal) obj2);
|
||||||
}
|
}
|
||||||
return Objects.equals(obj1, obj2);
|
return Objects.equals(obj1, obj2);
|
||||||
}
|
}
|
||||||
@ -305,13 +305,15 @@ public class ObjectUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果给定对象为{@code null} 返回默认值, 如果不为null 返回自定义handle处理后的返回值
|
* 如果给定对象为{@code null} 返回默认值, 如果不为null 返回自定义handle处理后的返回值
|
||||||
* @param source Object 类型对象
|
*
|
||||||
* @param handle 自定义的处理方法
|
* @param source Object 类型对象
|
||||||
|
* @param handle 自定义的处理方法
|
||||||
* @param defaultValue 默认为空的返回值
|
* @param defaultValue 默认为空的返回值
|
||||||
* @param <T> 被检查对象为{@code null}返回默认值,否则返回自定义handle处理后的返回值
|
* @param <T> 被检查对象为{@code null}返回默认值,否则返回自定义handle处理后的返回值
|
||||||
* @return
|
* @return 处理后的返回值
|
||||||
|
* @since 5.4.6
|
||||||
*/
|
*/
|
||||||
public static <T> T defaultIfNull(final Object source, Supplier<? extends T> handle, final T defaultValue) {
|
public static <T> T defaultIfNull(Object source, Supplier<? extends T> handle, final T defaultValue) {
|
||||||
if (Objects.nonNull(source)) {
|
if (Objects.nonNull(source)) {
|
||||||
return handle.get();
|
return handle.get();
|
||||||
}
|
}
|
||||||
@ -320,13 +322,15 @@ public class ObjectUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果给定对象为{@code null}或者""返回默认值, 否则返回自定义handle处理后的返回值
|
* 如果给定对象为{@code null}或者""返回默认值, 否则返回自定义handle处理后的返回值
|
||||||
* @param str String 类型
|
*
|
||||||
* @param handle 自定义的处理方法
|
* @param str String 类型
|
||||||
|
* @param handle 自定义的处理方法
|
||||||
* @param defaultValue 默认为空的返回值
|
* @param defaultValue 默认为空的返回值
|
||||||
* @param <T> 被检查对象为{@code null}或者 ""返回默认值,否则返回自定义handle处理后的返回值
|
* @param <T> 被检查对象为{@code null}或者 ""返回默认值,否则返回自定义handle处理后的返回值
|
||||||
* @return
|
* @return 处理后的返回值
|
||||||
|
* @since 5.4.6
|
||||||
*/
|
*/
|
||||||
public static <T> T defaultIfEmpty(final String str, Supplier<? extends T> handle, final T defaultValue) {
|
public static <T> T defaultIfEmpty(String str, Supplier<? extends T> handle, final T defaultValue) {
|
||||||
if (StrUtil.isNotEmpty(str)) {
|
if (StrUtil.isNotEmpty(str)) {
|
||||||
return handle.get();
|
return handle.get();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user