Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

1.9.5

Compare
Choose a tag to compare
@venusdrogon venusdrogon released this 17 Nov 04:16
· 393 commits to master since this release

具体参见 1.9.5 milestone

1.特性 🆕

  • ConvertUtil 添加 Map<K, V> toMap(K key1,V value1,K key2,V value2) 方法 fix #550

    该方法非常适合快速构造一个2个key的Map场景

    比如对于以下代码:

         Map<String, Long> map = new HashMap<>();
         map.put("itemId", itemId);
         map.put("memberId", memberId);
         memberFavoritesDao.findMemberFavoritesByMemberIdAndItemId(map);

    上面4行代码,可以重构成2行:

        Map<String, Long> map = ConvertUtil.toMap("itemId", itemId, "memberId", memberId);
        memberFavoritesDao.findMemberFavoritesByMemberIdAndItemId(map);
  • BeanPredicateUtil 添加 Predicate<T> equalPredicate(Map<String, ?> propertyNameAndPropertyValueMap) 方法 fix #113

    使用示例: 在list中查找 名字是 关羽,并且 年龄是30 的user

    此时你可以:

     User guanyu30 = new User("关羽", 30);
     List<User> list = ConvertUtil.toList(//
                     new User("张飞", 23),
                     new User("关羽", 24),
                     new User("刘备", 25),
                     guanyu30);
    
     Map<String, Object> map = ConvertUtil.toMap("name", "关羽", "age", 30);
    
     User result=com.feilong.core.util.CollectionsUtil.find(list, BeanPredicateUtil.<User> equalPredicate(map));
    
     assertEquals(guanyu30, result);

    寥寥几行代码,就可以搞定

  • BeanPredicateUtil.equalPredicate(String, V) 添加更多的 javadoc fix #546

  • 添加更多的单元测试

2.修改

  • ConvertUtil Map<K, V> toMap(Map.Entry<K, V>...mapEntrys) 方法重命名成 Map<K, V> toMapUseEntrys(Map.Entry<K, V>...mapEntrys) fix #549

3.移除

  • NumberFormatUtil 删除 String format(Number value,String numberPattern) 方法, 请直接调用 NumberUtil String toString(Number value,String toStringPattern) fix #245

4.Bug 修复 🐛

  • ParamUtil.toQueryStringUseArrayValueMap(Map<String, String[]>) 如果 map has value is null,返回 paramName= fix #372

    示例:

            Map<String, String[]> keyAndArrayMap = new LinkedHashMap<>();
    
            keyAndArrayMap.put("province", null);
            keyAndArrayMap.put("city", new String[] { "南通市" });
    
            assertEquals("province=&city=南通市", ParamUtil.toQueryStringUseArrayValueMap(keyAndArrayMap));