内容简介:feilong-core 2.1.0 发布了,feilong-core 是一个让 Java 开发更简便的工具包。 让你从大量重复的底层代码中脱身,提高工作效率; 让你的代码更简炼,易写、易读、易于维护; 文档地址: http://feilong-core.mydoc.i...
feilong-core 2.1.0 发布了,feilong-core 是一个让 Java 开发更简便的 工具 包。
- 让你从大量重复的底层代码中脱身,提高工作效率;
- 让你的代码更简炼,易写、易读、易于维护;
文档地址: http://feilong-core.mydoc.io/
单元测试数 增加至 2259
个, 单元测试覆盖率 增加至 91%
,javadoc 比率 83%
本次升级共有 10
处变更, 具体参见 2.1.0 milestone
[Feature] ????
#815 新建 DateUtil.nowTimestamp() 方法
在日常开发过程中,我们经常要生成文件/文件夹名字, 通常使用当前时间的 TIMESTAMP 命名
以前你需要写成 DateUtil.toString(new Date(), TIMESTAMP)
或者写成 DateUtil.nowString(TIMESTAMP)
(since 1.14.0)
更或者 DateUtil.toString(Calendar.getInstance().getTime(), DatePattern.TIMESTAMP)
此时你可以写成, (使用静态导入 static import更精简): DateUtil.nowTimestamp()
即可,较少开发量
#809 Dateutil 新增日期字符串区间的比较
com.feilong.core.date.DateUtil.isInTime(String beginDateString,String endDateString,String datePattern)
com.feilong.core.date.DateUtil.isInTime(Date date,String beginDateString,String endDateString,String datePattern)
判断当前时间 是否在格式是pattern的 beginDate 和 endDate两个时间之间.
使用场景:
比如当日达,判断下单的时间是否是 08:00-16:00 之间, 超过这个时间段的订单不能下
#807 Dateutil 新增 将一个时间格式字符串转成另外时间格式字符串方法
com.feilong.core.date.DateUtil.toString(String dateString,String oldPattern,String newPattern)
将一个 oldPattern
格式日期 dateString
字符串 使用新格式 newPattern
转成新的字符串.
示例:
DateUtil.toString("2020-01-06", "yyyy-MM-dd", "yyyy.MM.dd")="2020.01.06" DateUtil.toString("2020-01-06", "yyyy-MM-dd", "yyyy年MM月dd日")="2020年01月06日"
#816 新增 RandomUtil.createRandomString(int) 减少一步代码
从Alphabet.DECIMAL_AND_LOWERCASE_LETTERS_DISTINGUISHABLE
随机抽取字符串,拼接成指定长度length的字符串.
说明:
- 常用于生成验证码
- 接口传参,比如微信需要 nonce_str ,不长于32位的随机字符串
示例:
RandomUtil.createRandomString(5)
生成的结果是可能是IFSMB
#813 新增 CollectionsUtil.find(Iterable, Map<String, ?>) 方法
找到 iterable中,第一个 propertyName属性名称和值是 propertyValue是 propertyNameAndPropertyValueMap 的对应元素.
示例:
场景: 从list中查找name是 关羽,且年龄是24 的User对象
List<User> list = new ArrayList<>(); list.add(new User("张飞", 23)); list.add(new User("关羽", 24)); list.add(new User("刘备", 25)); list.add(new User("关羽", 50)); Map<String, ?> map = toMap("name", "关羽", "age", 24); LOGGER.info(JsonUtil.format(CollectionsUtil.find(list, map)));
返回:
{ "age": 24, "name": "关羽" }
说明:
返回第一个匹配对象
#808 CollectionsUtil 根据对象多个属性值去重
com.feilong.core.util.CollectionsUtil.removeDuplicate(Collection<O>, String...)
去重,返回指定属性 propertyNames 组合的值都不重复元素的新list (原集合对象不变).
比如下列user示例, 如果id相等,并且userInfo.age 属性值也相等 那么判定是重复对象
示例:
User user1 = new User(1L); user1.setUserInfo(new UserInfo(15)); User user2 = new User(1L); user2.setUserInfo(new UserInfo(16)); User user3 = new User(1L); user3.setUserInfo(new UserInfo(15)); List<User> list = toList(user1, user2, user3); List<User> removeDuplicate = CollectionsUtil.removeDuplicate(list, "id", "userInfo.age"); assertThat(removeDuplicate, contains(user1, user2)); assertSame(2, removeDuplicate.size());
注意:
- 如果原 objectCollection 是有序的,那么返回的结果参照原 objectCollection元素顺序
- 原 objectCollection不变
[Update]
- #818 基于
sonar8
修复坏味道 坏味道
[版本升级]
- none
[Javadoc]
- #811 修改
AggregateUtil.sum(Iterable<O>, String...)
javadoc - #810 修改
AggregateUtil.groupCount(Iterable<O>, String...)
javadoc - #812 完善
DefaultRuntimeException(String, Object...)
注释
[Remove]
- none
[Fix Bug]
- none
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Writing Windows VxDs and Device Drivers, Second Edition
Karen Hazzah / CMP / 1996-01-12 / USD 54.95
Software developer and author Karen Hazzah expands her original treatise on device drivers in the second edition of "Writing Windows VxDs and Device Drivers." The book and companion disk include the a......一起来看看 《Writing Windows VxDs and Device Drivers, Second Edition》 这本书的介绍吧!